AddLineTo() public method

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

        p = currentPoint;
        _graphicsPath.AddLineTo(p);
    }
Esempio n. 3
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. 4
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);
        // TODO: IIRC, `Vector2.zero` is a p/invoke.  Would it be safe to chain assignments here?  Would it be more
        // TODO: performant?  What about just calling `new Vector2(0f, 0f)`?
        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. 5
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, ry = r2;
        Vector2 p1 = _basicDraw.currentPoint, p2 = p;

        float _radian = (angle * Mathf.PI / 180.0f);
        // TODO: Do we have single-precision methods we can use here?  How's the performance?
        float _CosRadian = (float)Math.Cos(_radian);
        float _SinRadian = (float)Math.Sin(_radian);
        float temp1      = (p1.x - p2.x) / 2.0f;
        float 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. 6
0
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     _graphicsPath.AddLineTo(currentPoint);
 }
 //--------------------------------------------------------------------------------
 //Method: Render
 //--------------------------------------------------------------------------------
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     Vector2 p;
     p = currentPoint;
     _graphicsPath.AddLineTo(p);
 }
Esempio n. 8
0
    //-----
    public void CubicCurveTo(SVGPoint p1, SVGPoint p2, SVGPoint p, float width)
    {
        SVGPoint _point = new SVGPoint(0f, 0f);
        _point.SetValue(this._basicDraw.currentPoint);

        SVGPoint _p1 = new SVGPoint(0f, 0f);
        SVGPoint _p2 = new SVGPoint(0f, 0f);
        SVGPoint _p3 = new SVGPoint(0f, 0f);
        SVGPoint _p4 = new SVGPoint(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;
        }

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

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

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

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

        SVGPoint _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. 9
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. 10
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 = new Vector2(0f, 0f);
        Vector2 _p2 = new Vector2(0f, 0f);
        Vector2 _p3 = new Vector2(0f, 0f);
        Vector2 _p4 = new Vector2(0f, 0f);

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

        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(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);


        this._graphics.FillPath(_graphicsPath);

        //-------
        this._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);

        this._graphics.FillPath(_graphicsPath);

        //----------
        this._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);

        this._graphics.FillPath(_graphicsPath);

        //-------
        this._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);

        this._graphics.FillPath(_graphicsPath);
    }
Esempio n. 11
0
    //-----
    public void ArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, Vector2 p, float width)
    {
        float tx, ty, rx, ry;

        rx = r1;
        ry = r2;
        Vector2 p1 = new Vector2(0f, 0f);
        Vector2 p2 = new Vector2(0f, 0f);

        p1 = this._basicDraw.currentPoint;
        p2 = p;

        double trx2, try2, tx2, ty2;
        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;
        tx    = (_CosRadian * temp1) + (_SinRadian * temp2);
        ty    = (-_SinRadian * temp1) + (_CosRadian * temp2);

        trx2 = rx * rx;
        try2 = ry * ry;
        tx2  = tx * tx;
        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;

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

        float tm2;

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

        float tcx, tcy;

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

        float cx, cy;

        cx = _CosRadian * tcx - _SinRadian * tcy + ((p1.x + p2.x) / 2.0f);
        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 _angle, _delta;

        float tp, n;

        n       = (float)Math.Sqrt((ux * ux) + (uy * uy));
        tp      = ux;
        _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;
        _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 = new Vector2(0f, 0f);
        Vector2 _controlPoint2 = new Vector2(0f, 0f);

        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 = new Vector2(0f, 0f);
        Vector2 _p2 = new Vector2(0f, 0f);
        Vector2 _p3 = new Vector2(0f, 0f);
        Vector2 _p4 = new Vector2(0f, 0f);

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

        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(_controlPoint2, p2, width, ref _p5, ref _p6, ref _p7, ref _p8);

        float _half, _ihalf1, _ihalf2;

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

        float t_len1, t_len2;

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

        Vector2 tempPoint = new Vector2(0f, 0f);

        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;
        }

        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);
        this._graphics.FillPath(_graphicsPath);

        MoveTo(p);
    }
Esempio n. 12
0
    //-----
    public void RoundedRect(SVGPoint p1, SVGPoint p2, SVGPoint p3, SVGPoint p4, SVGPoint p5, SVGPoint p6, SVGPoint p7, SVGPoint 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);
        SVGPoint _p1 = new SVGPoint(0f, 0f);
        SVGPoint _p2 = new SVGPoint(0f, 0f);
        SVGPoint _p3 = new SVGPoint(0f, 0f);
        SVGPoint _p4 = new SVGPoint(0f, 0f);

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

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

        //-------
        this._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);

        this._graphics.FillPath(_graphicsPath);

        //-------
        this._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);

        this._graphics.FillPath(_graphicsPath);

        //----------
        this._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);

        this._graphics.FillPath(_graphicsPath);

        //-------
        this._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);

        this._graphics.FillPath(_graphicsPath);
    }
Esempio n. 13
0
    //-----
    public void QuadraticCurveTo(SVGPoint p1, SVGPoint p, float width)
    {
        SVGPoint _point = new SVGPoint(0f, 0f);
        _point.SetValue(this._basicDraw.currentPoint);

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

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

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

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

        SVGPoint _cp1, _cp2;
        _cp1 = this._graphics.GetCrossPoint(_p1, _p3, _p5, _p7);
        _cp2 = this._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);
        this._graphics.FillPath(_graphicsPath);

        MoveTo(p);
    }
Esempio n. 14
0
    //-----
    public void ArcTo(float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag, SVGPoint p, float width)
    {
        float tx, ty, rx, ry;
        rx = r1;
        ry = r2;
        SVGPoint p1 = new SVGPoint(0f, 0f);
        SVGPoint p2 = new SVGPoint(0f, 0f);
        p1.SetValue(this._basicDraw.currentPoint);
        p2.SetValue(p);

        double trx2, try2, tx2, ty2;
        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;
        tx = (_CosRadian * temp1) + (_SinRadian * temp2);
        ty = (-_SinRadian * temp1) + (_CosRadian * temp2);

        trx2 = rx * rx;
        try2 = ry * ry;
        tx2 = tx * tx;
        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;
        tm1 = (trx2 * try2 - trx2 * ty2 - try2 * tx2) / (trx2 * ty2 + try2 * tx2);
        tm1 = (tm1 < 0) ? 0 : tm1;

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

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

        float cx, cy;
        cx = _CosRadian * tcx - _SinRadian * tcy + ((p1.x + p2.x) / 2.0f);
        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 _angle, _delta;

        float tp, n;
        n = (float)Math.Sqrt((ux * ux) + (uy * uy));
        tp = ux;
        _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;
        _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
        SVGPoint _controlPoint1 = new SVGPoint(0f, 0f);
        SVGPoint _controlPoint2 = new SVGPoint(0f, 0f);

        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;
          }
        }
        //-----
        SVGPoint _p1 = new SVGPoint(0f, 0f);
        SVGPoint _p2 = new SVGPoint(0f, 0f);
        SVGPoint _p3 = new SVGPoint(0f, 0f);
        SVGPoint _p4 = new SVGPoint(0f, 0f);

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

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

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

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

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

        SVGPoint tempPoint = new SVGPoint(0f, 0f);
        if(t_len1 > t_len2) {
          tempPoint.SetValue(_p1);
          _p1.SetValue(_p2);
          _p2.SetValue(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.SetValue(_p7);
          _p7.SetValue(_p8);
          _p8.SetValue(tempPoint);
        }

        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);
        this._graphics.FillPath(_graphicsPath);

        MoveTo(p);
    }
Esempio n. 15
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. 16
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);
    }
 public void Render(SVGGraphicsPath _graphicsPath)
 {
     _graphicsPath.AddLineTo(currentPoint);
 }
Esempio n. 18
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. 19
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);
        // TODO: IIRC, `Vector2.zero` is a p/invoke.  Would it be safe to chain assignments here?  Would it be more
        // TODO: performant?  What about just calling `new Vector2(0f, 0f)`?
        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);
    }