GetBound() public méthode

public GetBound ( ) : Rect
Résultat Rect
    private void SetGradientVector(SVGGraphicsPath graphicsPath)
    {
        Rect bound = graphicsPath.GetBound();

        if (_linearGradElement.x1.unitType == SVGLengthType.Percentage)
        {
            _x1 = bound.x + (bound.width * _x1 / 100f);
        }
        if (_linearGradElement.y1.unitType == SVGLengthType.Percentage)
        {
            _y1 = bound.y + (bound.height * _y1 / 100f);
        }
        if (_linearGradElement.x2.unitType == SVGLengthType.Percentage)
        {
            _x2 = bound.x + (bound.width * _x2 / 100f);
        }
        if (_linearGradElement.y2.unitType == SVGLengthType.Percentage)
        {
            _y2 = bound.y + (bound.height * _y2 / 100f);
        }

        if (_linearGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox)
        {
            Vector2 _point = graphicsPath.matrixTransform.Transform(new Vector2(_x1, _y1));
            _x1 = _point.x;
            _y1 = _point.y;

            _point = graphicsPath.matrixTransform.Transform(new Vector2(_x2, _y2));
            _x2    = _point.x;
            _y2    = _point.y;
        }
    }
Exemple #2
0
    //-----
    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;
        }
    }
    private void SetGradientVector(SVGGraphicsPath graphicsPath)
    {
        Rect bound = graphicsPath.GetBound();
        if(_linearGradElement.x1.unitType == SVGLengthType.Percentage)
          _x1 = bound.x + (bound.width * _x1 / 100f);
        if(_linearGradElement.y1.unitType == SVGLengthType.Percentage)
          _y1 = bound.y + (bound.height * _y1 / 100f);
        if(_linearGradElement.x2.unitType == SVGLengthType.Percentage)
          _x2 = bound.x + (bound.width * _x2 / 100f);
        if(_linearGradElement.y2.unitType == SVGLengthType.Percentage)
          _y2 = bound.y + (bound.height * _y2 / 100f);

        if(_linearGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox) {
          Vector2 _point = graphicsPath.matrixTransform.Transform(new Vector2(_x1, _y1));
          _x1 = _point.x;
          _y1 = _point.y;

          _point = graphicsPath.matrixTransform.Transform(new Vector2(_x2, _y2));
          _x2 = _point.x;
          _y2 = _point.y;
        }
    }
    //-----
    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;
        }
    }