Exemplo n.º 1
0
        private void  AddLineCap(PointFP p1, PointFP p2, int lineCap)
        {
            if (lineCap == PenFP.LINECAP_BUTT || p1.Equals(p2))
            {
                return;
            }
            int dx  = p2.X - p1.X;
            int dy  = p2.Y - p1.Y;
            int len = PointFP.Distance(dx, dy);

            PointFP[] cap = lineCap == PenFP.LINECAP_ROUND?GraphicsPathFP.roundCap:GraphicsPathFP.squareCap;

            dx = MathFP.Mul(ff_rad, MathFP.Div(dx, len));
            dy = MathFP.Mul(ff_rad, MathFP.Div(dy, len));

            MatrixFP m = new MatrixFP(dx, dx, dy, -dy, p2.X, p2.Y);

            outline.AddMoveTo(new PointFP(0, GraphicsPathFP.One).Transform(m));
            for (int i = 0; i < cap.Length; i++)
            {
                outline.AddLineTo(new PointFP(cap[i]).Transform(m));
            }
            outline.AddLineTo(new PointFP(0, -GraphicsPathFP.One).Transform(m));
            outline.AddClose();
        }
Exemplo n.º 2
0
 public override void  Close()
 {
     closed = true;
     if (startCapP1 != null && startCapP2 != null && lastPoint != null && currPoint != null)
     {
         AddLineJoin(startCapP1.Equals(currPoint) ? lastPoint : currPoint, startCapP1, startCapP2);
     }
     LineTo(startPoint);
     started = false;
 }
Exemplo n.º 3
0
 public void  AddCurveTo(PointFP control, PointFP point)
 {
     if (control.Equals(point))
     {
         AddLineTo(point);
         return;
     }
     ExtendIfNeeded(1, 2);
     cmds[cmdsSize++] = CMD_QCURVETO;
     pnts[pntsSize++] = new PointFP(control);
     pnts[pntsSize++] = new PointFP(point);
 }
Exemplo n.º 4
0
        private void  AddLineJoin(PointFP lastPoint, PointFP currPoint, PointFP nextPoint)
        {
            if (lastPoint == null || currPoint == null || nextPoint == null || nextPoint.Equals(currPoint) || lastPoint.Equals(currPoint))
            {
                return;
            }

            PointFP p1 = null, p2 = null;
            LineFP  head, tail, lastHead, lastTail;

            CalcHeadTail(currPoint, nextPoint, head     = new LineFP(), tail = new LineFP());
            CalcHeadTail(lastPoint, currPoint, lastHead = new LineFP(), lastTail = new LineFP());
            bool    cross1, cross2, needLineJoin = false;
            PointFP pi1 = new PointFP();
            PointFP pi2 = new PointFP();

            cross1 = LineFP.Intersects(new LineFP(head.P1, tail.P1), new LineFP(lastHead.P1, lastTail.P1), pi1);
            cross2 = LineFP.Intersects(new LineFP(head.P2, tail.P2), new LineFP(lastHead.P2, lastTail.P2), pi2);
            if (cross1 && !cross2 && pi1.X != SingleFP.NaN)
            {
                p1           = lastTail.P2;
                p2           = head.P2;
                needLineJoin = true;
            }
            else if (!cross1 && cross2 && pi2.X != SingleFP.NaN)
            {
                p1           = lastTail.P1;
                p2           = head.P1;
                needLineJoin = true;
            }
            if (needLineJoin)
            {
                outline.AddMoveTo(cross1 ? pi1 : pi2);
                outline.AddLineTo(cross1 ? p2 : p1);
                if (lineJoin == PenFP.LINEJOIN_MITER)
                {
                    outline.AddLineTo(cross1 ? pi2 : pi1);
                }
                outline.AddLineTo(cross1 ? p1 : p2);
                outline.AddClose();
                if (lineJoin == PenFP.LINEJOIN_ROUND)
                {
                    AddLineCap(cross2 ? pi2 : pi1, currPoint, PenFP.LINECAP_ROUND);
                }
            }
        }
Exemplo n.º 5
0
 public void  AddCurveTo(PointFP control1, PointFP control2, PointFP point)
 {
     if (pnts[pntsSize - 1].Equals(control1))
     {
         AddCurveTo(control2, point);
         return;
     }
     if (point.Equals(control2))
     {
         AddCurveTo(control1, point);
         return;
     }
     ExtendIfNeeded(1, 3);
     cmds[cmdsSize++] = CMD_CCURVETO;
     pnts[pntsSize++] = new PointFP(control1);
     pnts[pntsSize++] = new PointFP(control2);
     pnts[pntsSize++] = new PointFP(point);
 }
Exemplo n.º 6
0
        public override void  LineTo(PointFP point)
        {
            if (point.Equals(currPoint))
            {
                return;
            }

            LineFP head, tail;

            CalcHeadTail(currPoint, point, head = new LineFP(), tail = new LineFP());

            if (drawingCurve)
            {
                if (lastCurveTail != null)
                {
                    curvePath1.AddLineTo(lastCurveTail.P1);
                    curvePath2.AddLineTo(lastCurveTail.P2);
                }
                lastCurveTail = new LineFP(tail);
            }
            else
            {
                if (needDrawStartCap)
                {
                    //AddLineCap(point, currPoint, startLineCap);
                    startCapP1       = new PointFP(currPoint);
                    startCapP2       = new PointFP(point);
                    needDrawStartCap = false;
                }
                AddLineJoin(lastPoint, currPoint, point);

                outline.AddMoveTo(head.P1);
                outline.AddLineTo(tail.P1);
                outline.AddLineTo(tail.P2);
                outline.AddLineTo(head.P2);
                outline.AddLineTo(head.P1);
                outline.AddClose();
                lastPoint = new PointFP(currPoint);
            }
            base.LineTo(point);
        }
Exemplo n.º 7
0
 public static bool IsEmpty(PointFP p)
 {
     return(Empty.Equals(p));
 }