private void SetGradientVector(SVGGraphicsPath graphicsPath)
{
Rect bound = graphicsPath.GetBound();
if(_radialGradElement.cx.unitType == SVGLengthType.Percentage)
_cx = bound.x + (bound.width * _cx / 100f);
if(_radialGradElement.cy.unitType == SVGLengthType.Percentage)
_cy = bound.y + (bound.height * _cy / 100f);
if(_radialGradElement.r.unitType == SVGLengthType.Percentage) {
Vector2 _p1 = new Vector2(bound.x, bound.y);
Vector2 _p2 = new Vector2(bound.x + bound.width, bound.y + bound.height);
_p1 = graphicsPath.matrixTransform.Transform(_p1);
_p2 = graphicsPath.matrixTransform.Transform(_p2);
float dd = (float)Math.Sqrt((_p2.x - _p1.x) * (_p2.x - _p1.x) + (_p2.y - _p1.y) * (_p2.y - _p1.y));
_r = (dd * _r / 100f);
}
if(_radialGradElement.fx.unitType == SVGLengthType.Percentage)
_fx = bound.x + (bound.width * _fx / 100f);
if(_radialGradElement.fy.unitType == SVGLengthType.Percentage)
_fy = bound.y + (bound.height * _fy / 100f);
if((float)Math.Sqrt((_cx - _fx) * (_cx - _fx) + (_cy - _fy) * (_cy - _fy)) > _r) {
Vector2 _cP = CrossPoint(_cx, _cy);
_fx = _cP.x;
_fy = _cP.y;
}
if(_radialGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox) {
Vector2 _point = new Vector2(_cx, _cy);
_point = graphicsPath.matrixTransform.Transform(_point);
_cx = _point.x;
_cy = _point.y;
_point = new Vector2(_fx, _fy);
_point = graphicsPath.matrixTransform.Transform(_point);
_fx = _point.x;
_fy = _point.y;
}
}