Esempio n. 1
0
    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;
        }
    }
Esempio n. 2
0
    //--------------------------------------------------------------------------------
    //Method: Render
    //--------------------------------------------------------------------------------
    public void Render(SVGGraphicsPath _graphicsPath)
    {
        Vector2 p;

        p = new Vector2(this._x, this._y);
        _graphicsPath.AddMoveTo(p);
    }
 //--------------------------------------------------------------------------------
 //Method: Render
 //--------------------------------------------------------------------------------
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     SVGPoint p, p1;
     p = currentPoint;
     p1 = controlPoint1;
     _graphicsPath.AddQuadraticCurveTo(p1, p);
 }
Esempio n. 4
0
    //--------------------------------------------------------------------------------
    //Method: Render
    //--------------------------------------------------------------------------------
    public void Render(SVGGraphicsPath _graphicsPath)
    {
        Vector2 p;

        p = currentPoint;
        _graphicsPath.AddLineTo(p);
    }
Esempio n. 5
0
    public SVGRadialGradientBrush(SVGRadialGradientElement radialGradElement, SVGGraphicsPath graphicsPath)
    {
        _radialGradElement = radialGradElement;
        Initialize();

        SetGradientVector(graphicsPath);
    }
Esempio n. 6
0
    protected override void CreateGraphicsPath()
    {
        _graphicsPath = new SVGGraphicsPath();

        _graphicsPath.Add(this);
        _graphicsPath.transformList = summaryTransformList;
    }
Esempio n. 7
0
 public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
 {
     Profiler.BeginSample("SVGGMoveTo.Render");
     pathDraw.MoveTo(path.matrixTransform.Transform(point));
     Profiler.EndSample();
     return(false);
 }
    public SVGRadialGradientBrush(SVGRadialGradientElement radialGradElement, SVGGraphicsPath graphicsPath)
    {
        _radialGradElement = radialGradElement;
        Initialize();

        SetGradientVector(graphicsPath);
    }
 //--------------------------------------------------------------------------------
 //Method: Render
 //--------------------------------------------------------------------------------
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     Vector2 p;
     p = currentPoint;
     _graphicsPath.AddArcTo(this._r1, this._r2, this._angle,
         this._largeArcFlag, this._sweepFlag, p);
 }
Esempio n. 10
0
 public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
 {
     Profiler.BeginSample("SVGGMoveTo.Render");
     pathDraw.MoveTo(path.matrixTransform.Transform(point));
     Profiler.EndSample();
     return false;
 }
Esempio n. 11
0
 public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
 {
     Profiler.BeginSample("SVGGArcAbs.Render");
     pathDraw.ArcTo(r1, r2, path.transformAngle + angle, largeArcFlag, sweepFlag, path.matrixTransform.Transform(point));
     Profiler.EndSample();
     return false;
 }
Esempio n. 12
0
    protected override void CreateGraphicsPath()
    {
        _graphicsPath = new SVGGraphicsPath();

        _graphicsPath.Add(this);
        _graphicsPath.transformList = summaryTransformList;
    }
Esempio n. 13
0
 public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
 {
     Profiler.BeginSample("SVGGArcAbs.Render");
     pathDraw.ArcTo(r1, r2, path.transformAngle + angle, largeArcFlag, sweepFlag, path.matrixTransform.Transform(point));
     Profiler.EndSample();
     return(false);
 }
Esempio n. 14
0
 public void ExpandBounds(SVGGraphicsPath path)
 {
     path.ExpandBounds(x, y);
     path.ExpandBounds(x + width, y);
     path.ExpandBounds(x + width, y + height);
     path.ExpandBounds(x, y + height);
 }
Esempio n. 15
0
    private void CreateGraphicsPath()
    {
        this._graphicsPath = new SVGGraphicsPath();

        this._graphicsPath.Add(this);
        this._graphicsPath.transformList = this.summaryTransformList;
    }
Esempio n. 16
0
 //Fill co Stroke trong do luon
 public void DrawPath(SVGGraphicsPath graphicsPath, float width)
 {
     _width     = width;
     isUseWidth = true;
     graphicsPath.RenderPath(this, false);
     isUseWidth = false;
 }
Esempio n. 17
0
 public void ExpandBounds(SVGGraphicsPath path)
 {
     path.ExpandBounds(x, y);
     path.ExpandBounds(x + width, y);
     path.ExpandBounds(x + width, y + height);
     path.ExpandBounds(x, y + height);
 }
Esempio n. 18
0
    public SVGLinearGradientBrush(SVGLinearGradientElement linearGradElement, SVGGraphicsPath graphicsPath)
    {
        _linearGradElement = linearGradElement;
        Initialize();

        SetGradientVector(graphicsPath);
        PreLocationProcess();
    }
Esempio n. 19
0
    //--------------------------------------------------------------------------------
    //Method: Render
    //--------------------------------------------------------------------------------
    public void Render(SVGGraphicsPath _graphicsPath)
    {
        Vector2 p;

        p = currentPoint;
        _graphicsPath.AddArcTo(this._r1, this._r2, this._angle,
                               this._largeArcFlag, this._sweepFlag, p);
    }
Esempio n. 20
0
    public SVGLinearGradientBrush(SVGLinearGradientElement linearGradElement, SVGGraphicsPath graphicsPath)
    {
        _linearGradElement = linearGradElement;
        Initialize();

        SetGradientVector(graphicsPath);
        PreLocationProcess();
    }
    //--------------------------------------------------------------------------------
    //Method: Render
    //--------------------------------------------------------------------------------
    public void Render(SVGGraphicsPath _graphicsPath)
    {
        Vector2 p, p1;

        p  = currentPoint;
        p1 = controlPoint1;
        _graphicsPath.AddQuadraticCurveTo(p1, p);
    }
Esempio n. 22
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;
        }
    }
Esempio n. 23
0
    //--------------------------------------------------------------------------------
    //Method: Render
    //--------------------------------------------------------------------------------
    public void Render(SVGGraphicsPath _graphicsPath)
    {
        Vector2 p, p1, p2;

        p1 = controlPoint1;
        p2 = controlPoint2;
        p  = currentPoint;
        _graphicsPath.AddCubicCurveTo(p1, p2, p);
    }
Esempio n. 24
0
 //Fill khong co Stroke, va ve stroke sau
 public void DrawPath(SVGGraphicsPath graphicsPath, float width, SVGColor?strokePathColor)
 {
     if (strokePathColor == null)
     {
         return;
     }
     SetColor(strokePathColor.Value.color);
     graphicsStroke.DrawPath(graphicsPath, width);
 }
Esempio n. 25
0
    //-----
    public void CubicCurveTo(Vector2 p1, Vector2 p2, Vector2 p, float width)
    {
        Vector2 _point = new Vector2(0f, 0f);

        _point = this._basicDraw.currentPoint;

        Vector2 _p1 = new Vector2(0f, 0f);
        Vector2 _p2 = new Vector2(0f, 0f);
        Vector2 _p3 = new Vector2(0f, 0f);
        Vector2 _p4 = new Vector2(0f, 0f);

        bool temp;

        temp = this._graphics.GetThickLine(_point, p1, width, ref _p1, ref _p2, ref _p3, ref _p4);
        if (temp == false)
        {
            QuadraticCurveTo(p2, p, width);
            return;
        }

        Vector2 _p5 = new Vector2(0f, 0f);
        Vector2 _p6 = new Vector2(0f, 0f);
        Vector2 _p7 = new Vector2(0f, 0f);
        Vector2 _p8 = new Vector2(0f, 0f);

        this._graphics.GetThickLine(p1, p2, width, ref _p5, ref _p6, ref _p7, ref _p8);

        Vector2 _p9  = new Vector2(0f, 0f);
        Vector2 _p10 = new Vector2(0f, 0f);
        Vector2 _p11 = new Vector2(0f, 0f);
        Vector2 _p12 = new Vector2(0f, 0f);

        this._graphics.GetThickLine(p2, p, width, ref _p9, ref _p10, ref _p11, ref _p12);

        Vector2 _cp1, _cp2, _cp3, _cp4;

        _cp1 = this._graphics.GetCrossPoint(_p1, _p3, _p5, _p7);
        _cp2 = this._graphics.GetCrossPoint(_p2, _p4, _p6, _p8);
        _cp3 = this._graphics.GetCrossPoint(_p5, _p7, _p9, _p11);
        _cp4 = this._graphics.GetCrossPoint(_p6, _p8, _p10, _p12);


        this._basicDraw.MoveTo(_point);
        this._basicDraw.CubicCurveTo(p1, p2, p);

        SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();

        _graphicsPath.AddMoveTo(_p2);
        _graphicsPath.AddCubicCurveTo(_cp2, _cp4, _p12);
        _graphicsPath.AddLineTo(_p11);
        _graphicsPath.AddCubicCurveTo(_cp3, _cp1, _p1);
        _graphicsPath.AddLineTo(_p2);
        this._graphics.FillPath(_graphicsPath);

        MoveTo(p);
    }
Esempio n. 26
0
 private void CreateGraphicsPath()
 {
     _graphicsPath = new SVGGraphicsPath();
     for(int i = 0; i < _segList.Count; i++) {
       ISVGDrawableSeg temp = _segList.GetItem(i) as ISVGDrawableSeg;
       if(temp != null)
     temp.Render(_graphicsPath);
     }
     _graphicsPath.transformList = summaryTransformList;
 }
Esempio n. 27
0
 public SVGRadialGradientBrush GetRadialGradientBrush(SVGGraphicsPath graphicsPath)
 {
     for (int i = 0; i < _radialGradList.Count; i++)
     {
         if (_radialGradList[i].id == _gradientID)
         {
             return(new SVGRadialGradientBrush(_radialGradList[i], graphicsPath));
         }
     }
     return(null);
 }
Esempio n. 28
0
    public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
    {
        int length = points.Count;
        pathDraw.MoveTo(path.matrixTransform.Transform(points[0]));
        for(int i = 1; i < length; i++) {
          Vector2 p = path.matrixTransform.Transform(points[i]);
          pathDraw.LineTo(p);
        }

        return false;
    }
Esempio n. 29
0
 //----------------------
 public SVGLinearGradientBrush GetLinearGradientBrush(SVGGraphicsPath graphicsPath)
 {
     for (int i = 0; i < this._linearGradList.Count; i++)
     {
         if (this._linearGradList[i].id == this._gradientID)
         {
             return(new SVGLinearGradientBrush(this._linearGradList[i], graphicsPath));
         }
     }
     return(null);
 }
Esempio n. 30
0
    public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
    {
        int length = points.Count;
        Vector2[] tPoints = new Vector2[length];

        for(int i = 0; i < length; i++)
          tPoints[i] = path.matrixTransform.Transform(points[i]);
        pathDraw.Polygon(tPoints);

        return true;
    }
Esempio n. 31
0
 private void CreateGraphicsPath()
 {
     _graphicsPath = new SVGGraphicsPath();
     for (int i = 0; i < _segList.Count; i++)
     {
         ISVGDrawableSeg temp = _segList.GetItem(i) as ISVGDrawableSeg;
         if (temp != null)
         {
             temp.Render(_graphicsPath);
         }
     }
     _graphicsPath.transformList = summaryTransformList;
 }
Esempio n. 32
0
    public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
    {
        int length = points.Count;

        pathDraw.MoveTo(path.matrixTransform.Transform(points[0]));
        for (int i = 1; i < length; i++)
        {
            Vector2 p = path.matrixTransform.Transform(points[i]);
            pathDraw.LineTo(p);
        }

        return(false);
    }
Esempio n. 33
0
 public void FillPath(SVGColor fillColor, SVGColor?strokePathColor, SVGGraphicsPath graphicsPath)
 {
     ResetSubBuffer();
     graphicsPath.RenderPath(this, true);
     if (strokePathColor != null)
     {
         EndSubBuffer(strokePathColor);
     }
     else
     {
         EndSubBuffer();
     }
 }
Esempio n. 34
0
 public void FillPath(SVGRadialGradientBrush radialGradientBrush, SVGColor?strokePathColor,
                      SVGGraphicsPath graphicsPath)
 {
     ResetSubBuffer();
     graphicsPath.RenderPath(this, true);
     if (strokePathColor != null)
     {
         EndSubBuffer(radialGradientBrush, strokePathColor);
     }
     else
     {
         EndSubBuffer(radialGradientBrush);
     }
 }
Esempio n. 35
0
    public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
    {
        int length = points.Count;

        Vector2[] tPoints = new Vector2[length];

        for (int i = 0; i < length; i++)
        {
            tPoints[i] = path.matrixTransform.Transform(points[i]);
        }
        pathDraw.Polygon(tPoints);

        return(true);
    }
Esempio n. 36
0
    public void Ellipse(Vector2 p, float rx, float ry, float angle, float width)
    {
        if ((int)width == 1)
        {
            Ellipse(p, rx, ry, angle);
        }
        else
        {
            int r1 = (int)(width / 2f);
            int r2 = (int)width - r1;

            //Vector2[] _points = new Vector2[1] { p };

            SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();
            _graphicsPath.AddEllipseTo(p, rx + r1, ry + r1, angle);
            _graphicsPath.AddEllipseTo(p, rx - r2, ry - r2, angle);

            _graphics.FillPath(_graphicsPath, p);
        }
    }
Esempio n. 37
0
    //Fill khong co Stroke, va ve stroke sau
    public void FillPath(SVGColor fillColor, SVGColor?strokePathColor,
                         float width,
                         SVGGraphicsPath graphicsPath)
    {
        graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath);
        if ((int)width == 1)
        {
            graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath);
        }
        else
        {
            graphicsFill.FillPath(fillColor, graphicsPath);
        }

        if (strokePathColor == null)
        {
            return;
        }
        SetColor(strokePathColor.Value.color);
    }
Esempio n. 38
0
    public void Circle(Vector2 p, float r, float width)
    {
        if ((int)width == 1)
        {
            Circle(p, r);
        }
        else
        {
            int r1 = (int)(width / 2f);
            int r2 = (int)width - r1;

            //Vector2[] _points = new Vector2[1];
            //_points[0] = new Vector2(p.x, p.y);

            SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();
            _graphicsPath.AddCircleTo(p, r + r1);
            _graphicsPath.AddCircleTo(p, r - r2);

            _graphics.FillPath(_graphicsPath, p);
        }
    }
Esempio n. 39
0
    public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
    {
        Vector2 p1 = new Vector2(x, y),
                p2 = new Vector2(x + width, y),
                p3 = new Vector2(x + width, y + height),
                p4 = new Vector2(x, y + height);

        if (rx == 0.0f && ry == 0.0f)
        {
            p1 = path.matrixTransform.Transform(p1);
            p2 = path.matrixTransform.Transform(p2);
            p3 = path.matrixTransform.Transform(p3);
            p4 = path.matrixTransform.Transform(p4);

            pathDraw.Rect(p1, p2, p3, p4);
        }
        else
        {
            float t_rx = (rx == 0.0f) ? ry : rx;
            float t_ry = (ry == 0.0f) ? rx : ry;

            t_rx = (t_rx > (width * 0.5f - 2f)) ? (width * 0.5f - 2f) : t_rx;
            t_ry = (t_ry > (height * 0.5f - 2f)) ? (height * 0.5f - 2f) : t_ry;

            float angle = path.transformAngle;

            Vector2 t_p1 = path.matrixTransform.Transform(new Vector2(p1.x + t_rx, p1.y));
            Vector2 t_p2 = path.matrixTransform.Transform(new Vector2(p2.x - t_rx, p2.y));
            Vector2 t_p3 = path.matrixTransform.Transform(new Vector2(p2.x, p2.y + t_ry));
            Vector2 t_p4 = path.matrixTransform.Transform(new Vector2(p3.x, p3.y - t_ry));

            Vector2 t_p5 = path.matrixTransform.Transform(new Vector2(p3.x - t_rx, p3.y));
            Vector2 t_p6 = path.matrixTransform.Transform(new Vector2(p4.x + t_rx, p4.y));
            Vector2 t_p7 = path.matrixTransform.Transform(new Vector2(p4.x, p4.y - t_ry));
            Vector2 t_p8 = path.matrixTransform.Transform(new Vector2(p1.x, p1.y + t_ry));

            pathDraw.RoundedRect(t_p1, t_p2, t_p3, t_p4, t_p5, t_p6, t_p7, t_p8, t_rx, t_ry, angle);
        }
        return(true);
    }
Esempio n. 40
0
    //Fill khong co Stroke, va ve stroke sau
    public void FillPath(SVGLinearGradientBrush linearGradientBrush,
                         SVGColor?strokePathColor,
                         float width,
                         SVGGraphicsPath graphicsPath)
    {
        graphicsFill.FillPath(linearGradientBrush, strokePathColor, graphicsPath);

        if ((int)width == 1)
        {
            graphicsFill.FillPath(linearGradientBrush, strokePathColor, graphicsPath);
        }
        else
        {
            graphicsFill.FillPath(linearGradientBrush, graphicsPath);
        }

        if (strokePathColor == null)
        {
            return;
        }
        SetColor(strokePathColor.Value.color);
    }
Esempio n. 41
0
    //Fill khong co Stroke, va ve stroke sau
    public void FillPath(SVGRadialGradientBrush radialGradientBrush,
                         SVGColor?strokePathColor,
                         float width,
                         SVGGraphicsPath graphicsPath)
    {
        graphicsFill.FillPath(radialGradientBrush, strokePathColor, graphicsPath);
        if ((int)width == 1)
        {
            graphicsFill.FillPath(radialGradientBrush, strokePathColor, graphicsPath);
        }
        else
        {
            graphicsFill.FillPath(radialGradientBrush, graphicsPath);
        }

        if (strokePathColor == null)
        {
            return;
        }
        SetColor(strokePathColor.Value.color);
        //graphicsPath.RenderPath(this, width, false);
    }
Esempio n. 42
0
    public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
    {
        Vector2 p1 = new Vector2(x, y),
            p2 = new Vector2(x + width, y),
            p3 = new Vector2(x + width, y + height),
            p4 = new Vector2(x, y + height);

        if(rx == 0.0f && ry == 0.0f) {
          p1 = path.matrixTransform.Transform(p1);
          p2 = path.matrixTransform.Transform(p2);
          p3 = path.matrixTransform.Transform(p3);
          p4 = path.matrixTransform.Transform(p4);

          pathDraw.Rect(p1, p2, p3, p4);
        } else {
          float t_rx = (rx == 0.0f) ? ry : rx;
          float t_ry = (ry == 0.0f) ? rx : ry;

          t_rx = (t_rx > (width * 0.5f - 2f)) ? (width * 0.5f - 2f) : t_rx;
          t_ry = (t_ry > (height * 0.5f - 2f)) ? (height * 0.5f - 2f) : t_ry;

          float angle = path.transformAngle;

          Vector2 t_p1 = path.matrixTransform.Transform(new Vector2(p1.x + t_rx, p1.y));
          Vector2 t_p2 = path.matrixTransform.Transform(new Vector2(p2.x - t_rx, p2.y));
          Vector2 t_p3 = path.matrixTransform.Transform(new Vector2(p2.x, p2.y + t_ry));
          Vector2 t_p4 = path.matrixTransform.Transform(new Vector2(p3.x, p3.y - t_ry));

          Vector2 t_p5 = path.matrixTransform.Transform(new Vector2(p3.x - t_rx, p3.y));
          Vector2 t_p6 = path.matrixTransform.Transform(new Vector2(p4.x + t_rx, p4.y));
          Vector2 t_p7 = path.matrixTransform.Transform(new Vector2(p4.x, p4.y - t_ry));
          Vector2 t_p8 = path.matrixTransform.Transform(new Vector2(p1.x, p1.y + t_ry));

          pathDraw.RoundedRect(t_p1, t_p2, t_p3, t_p4, t_p5, t_p6, t_p7, t_p8, t_rx, t_ry, angle);
        }
        return true;
    }
Esempio n. 43
0
 public void ExpandBounds(SVGGraphicsPath path)
 {
     int r = (int) r1 + (int) r2;
     path.ExpandBounds(point, r, r);
 }
Esempio n. 44
0
    //-----
    public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8,
		float r1, float r2,
		float angle, float width)
    {
        if ((int) width == 1)
        {
            RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2,
                angle);
            return;
        }

        Line(p1, p2, width);
        Line(p3, p4, width);
        Line(p5, p6, width);
        Line(p7, p8, width);
        Vector2 _p1 = Vector2.zero;
        Vector2 _p2 = Vector2.zero;
        Vector2 _p3 = Vector2.zero;
        Vector2 _p4 = Vector2.zero;

        _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4);

        Vector2 _p5 = Vector2.zero;
        Vector2 _p6 = Vector2.zero;
        Vector2 _p7 = Vector2.zero;
        Vector2 _p8 = Vector2.zero;

        //-------
        _graphics.GetThickLine(p3, p4, width, ref _p5, ref _p6, ref _p7, ref _p8);

        SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();

        _graphicsPath.AddMoveTo(_p4);
        _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p6);
        _graphicsPath.AddLineTo(_p5);
        _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p3);
        _graphicsPath.AddLineTo(_p4);

        _graphics.FillPath(_graphicsPath);

        //-------
        _graphics.GetThickLine(p5, p6, width, ref _p1, ref _p2, ref _p3, ref _p4);

        _graphicsPath.Reset();
        _graphicsPath.AddMoveTo(_p8);
        _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p2);
        _graphicsPath.AddLineTo(_p1);
        _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p7);
        _graphicsPath.AddLineTo(_p8);

        _graphics.FillPath(_graphicsPath);

        //----------
        _graphics.GetThickLine(p7, p8, width, ref _p5, ref _p6, ref _p7, ref _p8);

        _graphicsPath.Reset();
        _graphicsPath.AddMoveTo(_p4);
        _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p6);
        _graphicsPath.AddLineTo(_p5);
        _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p3);
        _graphicsPath.AddLineTo(_p4);

        _graphics.FillPath(_graphicsPath);

        //-------
        _graphics.GetThickLine(p1, p2, width, ref _p1, ref _p2, ref _p3, ref _p4);

        _graphicsPath.Reset();
        _graphicsPath.AddMoveTo(_p8);
        _graphicsPath.AddArcTo(r1 + (width/2f), r2 + (width/2f), angle, false, true, _p2);
        _graphicsPath.AddLineTo(_p1);
        _graphicsPath.AddArcTo(r1 - (width/2f), r2 - (width/2f), angle, false, false, _p7);
        _graphicsPath.AddLineTo(_p8);

        _graphics.FillPath(_graphicsPath);
    }
Esempio n. 45
0
    //-----
    public void ArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, Vector2 p, float width)
    {
        Profiler.BeginSample("SVGGraphicsStroke.ArcTo");
        float rx = r1;
        float ry = r2;
        Vector2 p1 = _basicDraw.currentPoint;
        Vector2 p2 = p;

        float temp1, temp2;
        float _radian = (angle*Mathf.PI/180.0f);
        float _CosRadian = (float) Math.Cos(_radian);
        float _SinRadian = (float) Math.Sin(_radian);
        temp1 = (p1.x - p2.x)/2.0f;
        temp2 = (p1.y - p2.y)/2.0f;
        float tx = (_CosRadian*temp1) + (_SinRadian*temp2);
        float ty = (-_SinRadian*temp1) + (_CosRadian*temp2);

        double trx2 = rx*rx;
        double try2 = ry*ry;
        double tx2 = tx*tx;
        double ty2 = ty*ty;

        double radiiCheck = tx2/trx2 + ty2/try2;
        if (radiiCheck > 1)
        {
            rx = (float) Math.Sqrt((float) radiiCheck)*rx;
            ry = (float) Math.Sqrt((float) radiiCheck)*ry;
            trx2 = rx*rx;
            try2 = ry*ry;
        }

        double tm1 = (trx2*try2 - trx2*ty2 - try2*tx2)/(trx2*ty2 + try2*tx2);
        tm1 = (tm1 < 0) ? 0 : tm1;

        float tm2 = (largeArcFlag == sweepFlag) ? -(float) Math.Sqrt((float) tm1) : (float) Math.Sqrt((float) tm1);

        float tcx = tm2*((rx*ty)/ry);
        float tcy = tm2*(-(ry*tx)/rx);

        float cx = _CosRadian*tcx - _SinRadian*tcy + ((p1.x + p2.x)/2.0f);
        float cy = _SinRadian*tcx + _CosRadian*tcy + ((p1.y + p2.y)/2.0f);

        float ux = (tx - tcx)/rx;
        float uy = (ty - tcy)/ry;
        float vx = (-tx - tcx)/rx;
        float vy = (-ty - tcy)/ry;

        float tp, n;
        n = (float) Math.Sqrt((ux*ux) + (uy*uy));
        tp = ux;
        float _angle = (uy < 0) ? -(float) Math.Acos(tp/n) : (float) Math.Acos(tp/n);
        _angle = _angle*180.0f/Mathf.PI;
        _angle %= 360f;

        n = (float) Math.Sqrt((ux*ux + uy*uy)*(vx*vx + vy*vy));
        tp = ux*vx + uy*vy;
        float _delta = (ux*vy - uy*vx < 0) ? -(float) Math.Acos(tp/n) : (float) Math.Acos(tp/n);
        _delta = _delta*180.0f/Mathf.PI;

        if (!sweepFlag && _delta > 0)
        {
            _delta -= 360f;
        }
        else if (sweepFlag && _delta < 0)
            _delta += 360f;

        _delta %= 360f;

        int number = 50;
        float deltaT = _delta/number;
        //---Get Control Point
        Vector2 _controlPoint1 = Vector2.zero;
        Vector2 _controlPoint2 = Vector2.zero;

        for (int i = 0; i <= number; i++)
        {
            float t_angle = (deltaT*i + _angle)*Mathf.PI/180.0f;
            _controlPoint1.x = _CosRadian*rx*(float) Math.Cos(t_angle) - _SinRadian*ry*(float) Math.Sin(t_angle) + cx;
            _controlPoint1.y = _SinRadian*rx*(float) Math.Cos(t_angle) + _CosRadian*ry*(float) Math.Sin(t_angle) + cy;
            if ((_controlPoint1.x != p1.x) && (_controlPoint1.y != p1.y))
            {
                i = number + 1;
            }
        }

        for (int i = number; i >= 0; i--)
        {
            float t_angle = (deltaT*i + _angle)*Mathf.PI/180.0f;
            _controlPoint2.x = _CosRadian*rx*(float) Math.Cos(t_angle) - _SinRadian*ry*(float) Math.Sin(t_angle) + cx;
            _controlPoint2.y = _SinRadian*rx*(float) Math.Cos(t_angle) + _CosRadian*ry*(float) Math.Sin(t_angle) + cy;
            if ((_controlPoint2.x != p2.x) && (_controlPoint2.y != p2.y))
            {
                i = -1;
            }
        }
        //-----
        Vector2 _p1 = Vector2.zero;
        Vector2 _p2 = Vector2.zero;
        Vector2 _p3 = Vector2.zero;
        Vector2 _p4 = Vector2.zero;

        _graphics.GetThickLine(p1, _controlPoint1, width, ref _p1, ref _p2, ref _p3, ref _p4);

        Vector2 _p5 = Vector2.zero;
        Vector2 _p6 = Vector2.zero;
        Vector2 _p7 = Vector2.zero;
        Vector2 _p8 = Vector2.zero;

        _graphics.GetThickLine(_controlPoint2, p2, width, ref _p5, ref _p6, ref _p7, ref _p8);

        float _half = width/2f;
        float _ihalf1 = _half;
        float _ihalf2 = width - _ihalf1 + 0.5f;
        //-----

        float t_len1 = (_p1.x - cx)*(_p1.x - cx) + (_p1.y - cy)*(_p1.y - cy);
        float t_len2 = (_p2.x - cx)*(_p2.x - cx) + (_p2.y - cy)*(_p2.y - cy);

        Vector2 tempPoint;
        if (t_len1 > t_len2)
        {
            tempPoint = _p1;
            _p1 = _p2;
            _p2 = tempPoint;
        }

        t_len1 = (_p7.x - cx)*(_p7.x - cx) + (_p7.y - cy)*(_p7.y - cy);
        t_len2 = (_p8.x - cx)*(_p8.x - cx) + (_p8.y - cy)*(_p8.y - cy);

        if (t_len1 > t_len2)
        {
            tempPoint = _p7;
            _p7 = _p8;
            _p8 = tempPoint;
        }

        Profiler.BeginSample("SVGGraphicsStroke.ArcTo[CreateGraphicsPath]");
        SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();
        _graphicsPath.AddMoveTo(_p2);
        _graphicsPath.AddArcTo(r1 + _ihalf1, r2 + _ihalf1, angle, largeArcFlag, sweepFlag, _p8);
        _graphicsPath.AddLineTo(_p7);
        _graphicsPath.AddArcTo(r1 - _ihalf2, r2 - _ihalf2, angle, largeArcFlag, !sweepFlag, _p1);
        _graphicsPath.AddLineTo(_p2);
        Profiler.EndSample();
        Profiler.BeginSample("SVGGraphicsStroke.ArcTo[FillPath]");
        _graphics.FillPath(_graphicsPath);
        Profiler.EndSample();
        MoveTo(p);
        Profiler.EndSample();
    }
Esempio n. 46
0
    //-----
    public void QuadraticCurveTo(Vector2 p1, Vector2 p, float width)
    {
        Vector2 _point = Vector2.zero;
        _point = _basicDraw.currentPoint;

        Vector2 _p1 = Vector2.zero;
        Vector2 _p2 = Vector2.zero;
        Vector2 _p3 = Vector2.zero;
        Vector2 _p4 = Vector2.zero;

        _graphics.GetThickLine(_point, p1, width, ref _p1, ref _p2, ref _p3, ref _p4);

        Vector2 _p5 = Vector2.zero;
        Vector2 _p6 = Vector2.zero;
        Vector2 _p7 = Vector2.zero;
        Vector2 _p8 = Vector2.zero;

        _graphics.GetThickLine(p1, p, width, ref _p5, ref _p6, ref _p7, ref _p8);

        Vector2 _cp1, _cp2;
        _cp1 = _graphics.GetCrossPoint(_p1, _p3, _p5, _p7);
        _cp2 = _graphics.GetCrossPoint(_p2, _p4, _p6, _p8);

        SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();
        _graphicsPath.AddMoveTo(_p2);
        _graphicsPath.AddQuadraticCurveTo(_cp2, _p8);
        _graphicsPath.AddLineTo(_p7);
        _graphicsPath.AddQuadraticCurveTo(_cp1, _p1);
        _graphicsPath.AddLineTo(_p2);
        _graphics.FillPath(_graphicsPath);

        MoveTo(p);
    }
Esempio n. 47
0
    //-----
    public void Ellipse(Vector2 p, float rx, float ry, float angle, float width)
    {
        if ((int) width == 1)
        {
            Ellipse(p, rx, ry, angle);
        }
        else
        {
            int r1 = (int) (width/2f);
            int r2 = (int) width - r1;

            //Vector2[] _points = new Vector2[1] { p };

            SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();
            _graphicsPath.AddEllipseTo(p, rx + r1, ry + r1, angle);
            _graphicsPath.AddEllipseTo(p, rx - r2, ry - r2, angle);

            _graphics.FillPath(_graphicsPath, p);
        }
    }
Esempio n. 48
0
 //-----
 //Fill co Stroke trong do luon
 public void DrawPath(SVGGraphicsPath graphicsPath, float width)
 {
     _width = width;
     isUseWidth = true;
     graphicsPath.RenderPath(this, false);
     isUseWidth = false;
 }
Esempio n. 49
0
 //================================================================================
 //--------------------------------------------------------------------------------
 //Methods: DrawPath
 //--------------------------------------------------------------------------------
 public void DrawPath(SVGGraphicsPath graphicsPath)
 {
     graphicsPath.RenderPath(this, false);
 }
Esempio n. 50
0
 public bool Render(SVGGraphicsPath path, ISVGPathDraw pathDraw)
 {
     pathDraw.QuadraticCurveTo(path.matrixTransform.Transform(p1), path.matrixTransform.Transform(p));
     return false;
 }
Esempio n. 51
0
 public void ExpandBounds(SVGGraphicsPath path)
 {
     path.ExpandBounds(points);
 }
Esempio n. 52
0
    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;
        }
    }
 //--------------------------------------------------------------------------------
 //Method: Render
 //--------------------------------------------------------------------------------
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     Vector2 p;
     p = currentPoint;
     _graphicsPath.AddLineTo(p);
 }
Esempio n. 54
0
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     _graphicsPath.AddArcTo(this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag, currentPoint);
 }
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     _graphicsPath.AddCubicCurveTo(controlPoint1, controlPoint2, currentPoint);
 }
Esempio n. 56
0
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     _graphicsPath.AddLineTo(currentPoint);
 }
Esempio n. 57
0
    //-----
    public void Circle(Vector2 p, float r, float width)
    {
        if ((int) width == 1)
        {
            Circle(p, r);
        }
        else
        {
            int r1 = (int) (width/2f);
            int r2 = (int) width - r1;

            //Vector2[] _points = new Vector2[1];
            //_points[0] = new Vector2(p.x, p.y);

            SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();
            _graphicsPath.AddCircleTo(p, r + r1);
            _graphicsPath.AddCircleTo(p, r - r2);

            _graphics.FillPath(_graphicsPath, p);
        }
    }
Esempio n. 58
0
    //-----
    public void CubicCurveTo(Vector2 p1, Vector2 p2, Vector2 p, float width)
    {
        Vector2 _point = Vector2.zero;
        _point = _basicDraw.currentPoint;

        Vector2 _p1 = Vector2.zero;
        Vector2 _p2 = Vector2.zero;
        Vector2 _p3 = Vector2.zero;
        Vector2 _p4 = Vector2.zero;

        bool temp;
        temp = _graphics.GetThickLine(_point, p1, width, ref _p1, ref _p2, ref _p3, ref _p4);
        if (temp == false)
        {
            QuadraticCurveTo(p2, p, width);
            return;
        }

        Vector2 _p5 = Vector2.zero;
        Vector2 _p6 = Vector2.zero;
        Vector2 _p7 = Vector2.zero;
        Vector2 _p8 = Vector2.zero;

        _graphics.GetThickLine(p1, p2, width, ref _p5, ref _p6, ref _p7, ref _p8);

        Vector2 _p9 = Vector2.zero;
        Vector2 _p10 = Vector2.zero;
        Vector2 _p11 = Vector2.zero;
        Vector2 _p12 = Vector2.zero;

        _graphics.GetThickLine(p2, p, width, ref _p9, ref _p10, ref _p11, ref _p12);

        Vector2 _cp1, _cp2, _cp3, _cp4;
        _cp1 = _graphics.GetCrossPoint(_p1, _p3, _p5, _p7);
        _cp2 = _graphics.GetCrossPoint(_p2, _p4, _p6, _p8);
        _cp3 = _graphics.GetCrossPoint(_p5, _p7, _p9, _p11);
        _cp4 = _graphics.GetCrossPoint(_p6, _p8, _p10, _p12);

        _basicDraw.MoveTo(_point);
        _basicDraw.CubicCurveTo(p1, p2, p);

        SVGGraphicsPath _graphicsPath = new SVGGraphicsPath();
        _graphicsPath.AddMoveTo(_p2);
        _graphicsPath.AddCubicCurveTo(_cp2, _cp4, _p12);
        _graphicsPath.AddLineTo(_p11);
        _graphicsPath.AddCubicCurveTo(_cp3, _cp1, _p1);
        _graphicsPath.AddLineTo(_p2);
        _graphics.FillPath(_graphicsPath);

        MoveTo(p);
    }
Esempio n. 59
0
 //----------------------
 public SVGRadialGradientBrush GetRadialGradientBrush(SVGGraphicsPath graphicsPath)
 {
     for(int i=0; i < this._radialGradList.Count; i++) {
       if(this._radialGradList[i].id == this._gradientID) {
     return new SVGRadialGradientBrush(this._radialGradList[i], graphicsPath);
       }
     }
     return null;
 }
Esempio n. 60
0
 public void ExpandBounds(SVGGraphicsPath path)
 {
     path.ExpandBounds(p1);
     path.ExpandBounds(p);
 }