Exemplo n.º 1
0
        public static GraphicsPathFP CreateLine(int ff_x1, int ff_y1, int ff_x2, int ff_y2)
        {
            GraphicsPathFP path = new GraphicsPathFP();

            path.AddMoveTo(new PointFP(ff_x1, ff_y1));
            path.AddLineTo(new PointFP(ff_x2, ff_y2));
            return(path);
        }
Exemplo n.º 2
0
        public static GraphicsPathFP CreatePolyline(PointFP[] points)
        {
            GraphicsPathFP path = new GraphicsPathFP();

            if (points.Length > 0)
            {
                path.AddMoveTo(points[0]);
                for (int i = 1; i < points.Length; i++)
                {
                    path.AddLineTo(points[i]);
                }
            }
            return(path);
        }
Exemplo n.º 3
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.º 4
0
        public static GraphicsPathFP CreateRoundRect(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_rx, int ff_ry)
        {
            int            ff_rmax;
            int            FF_PI = MathFP.PI;
            GraphicsPathFP path  = new GraphicsPathFP();

            path.AddMoveTo(new PointFP(ff_xmin + ff_rx, ff_ymin));
            path.AddLineTo(new PointFP(ff_xmax - ff_rx, ff_ymin));
            ff_rmax = MathFP.Min(ff_xmax - ff_xmin, ff_ymax - ff_ymin) / 2;
            if (ff_rx > ff_rmax)
            {
                ff_rx = ff_rmax;
            }
            if (ff_ry > ff_rmax)
            {
                ff_ry = ff_rmax;
            }
            if (ff_rx != 0 && ff_ry != 0)
            {
                path.AddPath(GraphicsPathFP.CreateArc(ff_xmax - ff_rx * 2, ff_ymin, ff_xmax, ff_ymin + ff_ry * 2, (-FF_PI) / 2, 0, false, false));
            }
            path.AddLineTo(new PointFP(ff_xmax, ff_ymin + ff_ry));
            path.AddLineTo(new PointFP(ff_xmax, ff_ymax - ff_ry));
            if (ff_rx != 0 && ff_ry != 0)
            {
                path.AddPath(GraphicsPathFP.CreateArc(ff_xmax - ff_rx * 2, ff_ymax - ff_ry * 2, ff_xmax, ff_ymax, 0, FF_PI / 2, false, false));
            }
            path.AddLineTo(new PointFP(ff_xmax - ff_rx, ff_ymax));
            path.AddLineTo(new PointFP(ff_xmin + ff_rx, ff_ymax));
            if (ff_rx != 0 && ff_ry != 0)
            {
                path.AddPath(GraphicsPathFP.CreateArc(ff_xmin, ff_ymax - ff_ry * 2, ff_xmin + ff_rx * 2, ff_ymax, FF_PI / 2, FF_PI, false, false));
            }
            path.AddLineTo(new PointFP(ff_xmin, ff_ymax - ff_ry));
            path.AddLineTo(new PointFP(ff_xmin, ff_ymin + ff_ry));
            if (ff_rx != 0 && ff_ry != 0)
            {
                path.AddPath(GraphicsPathFP.CreateArc(ff_xmin, ff_ymin, ff_xmin + ff_rx * 2, ff_ymin + ff_ry * 2, -FF_PI, (-FF_PI) / 2, false, false));
            }
            path.AddClose();
            return(path);
        }
Exemplo n.º 5
0
        public static GraphicsPathFP  CreateArc(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_startangle, int ff_sweepangle, bool closed, bool standalone)
        {
            if (ff_sweepangle < 0)
            {
                ff_startangle += ff_sweepangle;
                ff_sweepangle  = -ff_sweepangle;
            }
            int segments = MathFP.Round(MathFP.Div(4 * MathFP.Abs(ff_sweepangle), MathFP.PI)) >> SingleFP.DecimalBits;

            if (segments == 0)
            {
                segments = 1;
            }
            GraphicsPathFP path = new GraphicsPathFP();
            int            ff_darg = ff_sweepangle / segments;
            int            ff_arg = ff_startangle;
            int            ff_lastcos = MathFP.Cos(ff_startangle);
            int            ff_lastsin = MathFP.Sin(ff_startangle);
            int            ff_xc = (ff_xmin + ff_xmax) / 2;
            int            ff_yc = (ff_ymin + ff_ymax) / 2;
            int            ff_rx = (ff_xmax - ff_xmin) / 2;
            int            ff_ry = (ff_ymax - ff_ymin) / 2;
            int            ff_RXBETA = MathFP.Mul(17381, ff_rx);
            int            ff_RYBETA = MathFP.Mul(17381, ff_ry);
            int            ff_currcos, ff_currsin, ff_x1, ff_y1, ff_x2, ff_y2;

            if (closed)
            {
                path.AddMoveTo(new PointFP(ff_xc, ff_yc));
            }

            for (int i = 1; i <= segments; i++)
            {
                ff_arg     = i == segments?ff_startangle + ff_sweepangle:ff_arg + ff_darg;
                ff_currcos = MathFP.Cos(ff_arg);
                ff_currsin = MathFP.Sin(ff_arg);
                ff_x1      = ff_xc + MathFP.Mul(ff_rx, ff_lastcos);
                ff_y1      = ff_yc + MathFP.Mul(ff_ry, ff_lastsin);
                ff_x2      = ff_xc + MathFP.Mul(ff_rx, ff_currcos);
                ff_y2      = ff_yc + MathFP.Mul(ff_ry, ff_currsin);
                if (i == 1)
                {
                    if (closed)
                    {
                        path.AddLineTo(new PointFP(ff_x1, ff_y1));
                    }
                    else
                    if (standalone)
                    {
                        path.AddMoveTo(new PointFP(ff_x1, ff_y1));
                    }
                }

                path.AddCurveTo(
                    new PointFP(ff_x1 - MathFP.Mul(ff_RXBETA, ff_lastsin), ff_y1 + MathFP.Mul(ff_RYBETA, ff_lastcos)),
                    new PointFP(ff_x2 + MathFP.Mul(ff_RXBETA, ff_currsin), ff_y2 - MathFP.Mul(ff_RYBETA, ff_currcos)),
                    new PointFP(ff_x2, ff_y2));
                ff_lastcos = ff_currcos;
                ff_lastsin = ff_currsin;
            }
            if (closed)
            {
                path.AddClose();
            }
            return(path);
        }
Exemplo n.º 6
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();
        }