Example #1
0
        public void DrawBeziers(PenX pen, Point[] points)
        {
            lock (this)
            {
                int length = points.Length;
                if (length < 4)
                {
                    return;
                }

                graphics.Pen = PenX.ToPenFP(pen);
                GraphicsPathFP path = new GraphicsPathFP();
                path.AddMoveTo(new PointFP(SingleFP.FromInt(points[0].X), SingleFP.FromInt(points[0].Y)));
                for (int i = 1; i <= length - 3; i += 3)
                {
                    Point p1 = points[i];
                    Point p2 = points[i + 1];
                    Point p3 = points[i + 2];
                    path.AddCurveTo(
                        new PointFP(SingleFP.FromInt(p1.X), SingleFP.FromInt(p1.Y)),
                        new PointFP(SingleFP.FromInt(p2.X), SingleFP.FromInt(p2.Y)),
                        new PointFP(SingleFP.FromInt(p3.X), SingleFP.FromInt(p3.Y)));
                }
                graphics.Matrix = matrix == null ? null : matrix.matrix;
                graphics.DrawPath(path);
            }
        }
Example #2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 15JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Strokes the outline of a IShape using the settings of the current
         * Graphics2D context.
         * @param brush the brush used to fill the shape.
         * @param shape the IShape to be rendered.
         */
        public void Fill(Brush brush, IShape shape)
        {
            if (brush != null)
            {
                _graphicsFP.SetBrush(brush._wrappedBrushFP);
                _defaultBrush = brush;
            }

            PathIterator pathIterator = shape.GetPathIterator(null);

            int[]          coords         = new int[6];
            GraphicsPathFP graphicsPathFP = new GraphicsPathFP();
            PointFP        pointFP1       = new PointFP();
            PointFP        pointFPCtl1    = new PointFP();
            PointFP        pointFPCtl2    = new PointFP();

            while (!pathIterator.IsDone())
            {
                int type = pathIterator.CurrentSegment(coords);
                switch (type)
                {
                case PathIterator.SEG_MOVETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddMoveTo(pointFP1);
                    break;

                case PathIterator.SEG_CLOSE:
                    graphicsPathFP.AddClose();
                    break;

                case PathIterator.SEG_LINETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddLineTo(pointFP1);
                    break;

                case PathIterator.SEG_QUADTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                   coords[3] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddQuadTo(pointFPCtl1, pointFP1);
                    break;

                case PathIterator.SEG_CUBICTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFPCtl2.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                      coords[3] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[4] << SingleFP.DECIMAL_BITS,
                                   coords[5] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddCurveTo(pointFPCtl1, pointFPCtl2, pointFP1);
                    break;
                }
                pathIterator.Next();
            }
            _graphicsFP.FillPath(graphicsPathFP);
        }
Example #3
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 15JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Strokes the outline of a IShape using the settings of the current
         * Graphics2D context.
         * @param pen the pen used to stroke the shape.
         * @param shape the IShape to be rendered.
         */
        public void Draw(Pen pen, IShape shape)
        {
            SetGraphicsFPPenAttribute(pen);
            PathIterator pathIterator = shape.GetPathIterator(null);

            int[]          coords         = new int[6];
            GraphicsPathFP graphicsPathFP = new GraphicsPathFP();
            PointFP        pointFP1       = new PointFP();
            PointFP        pointFPCtl1    = new PointFP();
            PointFP        pointFPCtl2    = new PointFP();

            while (!pathIterator.IsDone())
            {
                int type = pathIterator.CurrentSegment(coords);
                switch (type)
                {
                case PathIterator.SEG_MOVETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddMoveTo(pointFP1);
                    break;

                case PathIterator.SEG_CLOSE:
                    graphicsPathFP.AddClose();
                    break;

                case PathIterator.SEG_LINETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddLineTo(pointFP1);
                    break;

                case PathIterator.SEG_QUADTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                   coords[3] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddQuadTo(pointFPCtl1, pointFP1);
                    break;

                case PathIterator.SEG_CUBICTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFPCtl2.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                      coords[3] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[4] << SingleFP.DECIMAL_BITS,
                                   coords[5] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddCurveTo(pointFPCtl1, pointFPCtl2, pointFP1);
                    break;
                }
                pathIterator.Next();
            }
            _graphicsFP.DrawPath(graphicsPathFP);
        }
Example #4
0
 public void DrawBezier(PenX pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 {
     lock (this)
     {
         graphics.Pen = PenX.ToPenFP(pen);
         GraphicsPathFP path = new GraphicsPathFP();
         path.AddMoveTo(new PointFP(SingleFP.FromFloat(x1), SingleFP.FromFloat(y1)));
         path.AddCurveTo(
             new PointFP(SingleFP.FromFloat(x2), SingleFP.FromFloat(y2)),
             new PointFP(SingleFP.FromFloat(x3), SingleFP.FromFloat(y3)),
             new PointFP(SingleFP.FromFloat(x4), SingleFP.FromFloat(y4)));
         graphics.Matrix = matrix == null ? null : matrix.matrix;
         graphics.DrawPath(path);
     }
 }