SVGRadialGradientBrush.Percent C# (CSharp) Method

Percent() private method

private Percent ( float x, float y ) : float
x float
y float
return float
    private float Percent(float x, float y)
    {
        Vector2 _cP = CrossPoint(x, y);

        //float d1 = (float)Math.Sqrt((_cP.x - x)*(_cP.x - x)+(_cP.y - y)*(_cP.y - y));
        float d2 = (float)Math.Sqrt((_fx - x) * (_fx - x) + (_fy - y) * (_fy - y));
        float dd = (float)Math.Sqrt((_cP.x - _fx) * (_cP.x - _fx) + (_cP.y - _fy) * (_cP.y - _fy));
        //0 giua, 1 ngoai
        int vt = 0;
        if(d2 > dd)
          vt = 1;

        int _reflectTimes;
        float _remainder;

        switch(_spreadMethod) {
        case SVGSpreadMethod.Pad:
          if(vt == 1)
        return 100f;
          return (d2 / dd * 100f);
        case SVGSpreadMethod.Reflect:
          _reflectTimes = (int)(d2 / dd);
          _remainder = d2 - (dd * (float)_reflectTimes);
          int _od = (int)(_reflectTimes) % 2;
          return ((100f * _od) + (1 - 2 * _od) * (_remainder / dd * 100f));
        case SVGSpreadMethod.Repeat:
          _reflectTimes = (int)(d2 / dd);
          _remainder = d2 - (dd * (float)_reflectTimes);
          return (_remainder / dd * 100f);
        }

        return 100f;
    }