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); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- 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); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * fill a oval. * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax */ public void FillOval(int ffXmin, int ffYmin, int ffXmax, int ffYmax) { var path = GraphicsPathFP.CreateOval(ffXmin, ffYmin, ffXmax, ffYmax); path.AddClose(); FillPath(path); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * * @param pathFP * @param outline * @param lineStyle */ public GraphicsPathOutlineFP(GraphicsPathFP outline, PenFP lineStyle) { _outline = outline; _ffRad = lineStyle.Width / 2; _startLineCap = lineStyle.StartCap; _endLineCap = lineStyle.EndCap; _lineJoin = lineStyle.LineJoin; }
private void CurveBegin(PointFP control) { AddLineJoin(_lastPoint, _currPoint, control); _drawingCurve = true; _curvePath1 = new GraphicsPathFP(); _curvePath2 = new GraphicsPathFP(); _curveBegin = new PointFP(_currPoint); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- 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); }
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); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a path. * @param path */ public void DrawPath(GraphicsPathFP path) { if (_lineStyle.DashArray != null) { var newlineStyle = new PenFP(_lineStyle.Brush, _lineStyle.Width, PenFP.LINECAP_BUTT, PenFP.LINECAP_BUTT, PenFP.LINEJOIN_MITER) { DashArray = _lineStyle.DashArray }; var dasher = new GraphicsPathDasherFP(path, newlineStyle.DashArray, 0); var newPath = dasher.GetDashedGraphicsPath(); _renderer.DrawPath(newPath.CalcOutline(newlineStyle), _matrix, _lineStyle.Brush, GraphicsPathRendererFP.MODE_ZERO); } else { _renderer.DrawPath(path.CalcOutline(_lineStyle), _matrix, _lineStyle.Brush, GraphicsPathRendererFP.MODE_ZERO); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a round rect * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax * @param ff_rx the radius of the round circle. * @param ff_ry the radius of the round circle. */ public void DrawRoundRect(int ffXmin, int ffYmin, int ffXmax, int ffYmax, int ffRx, int ffRy) { DrawPath(GraphicsPathFP.CreateRoundRect(ffXmin, ffYmin, ffXmax, ffYmax, ffRx, ffRy)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a oval. * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax */ public void DrawOval(int ffXmin, int ffYmin, int ffXmax, int ffYmax) { DrawPath(GraphicsPathFP.CreateOval(ffXmin, ffYmin, ffXmax, ffYmax)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * fill a path. * @param path */ public void FillPath(GraphicsPathFP path) { _renderer.DrawPath(path, _matrix, _fillStyle, _paintMode); }
private void CurveEnd(PointFP control1, PointFP control2, PointFP curveEnd) { _drawingCurve = false; if (_needDrawStartCap) { _startCapP1 = new PointFP(_curveBegin); _startCapP2 = new PointFP(control1); _needDrawStartCap = false; } var head = new LineFP(); var tail = new LineFP(); CalcHeadTail(_curveBegin, control1, head, new LineFP()); _outline.AddMoveTo(head.Pt1); _outline.AddPath(_curvePath1); CalcHeadTail(control2, curveEnd, new LineFP(), tail); _outline.AddLineTo(tail.Pt1); _outline.AddLineTo(tail.Pt2); _outline.ExtendIfNeeded(_curvePath1._cmdsSize, _curvePath1._pntsSize); int j = _curvePath2._pntsSize - 1; for (int i = _curvePath2._cmdsSize - 1; i >= 0; i--) { _outline.AddLineTo(_curvePath2._pnts[j--]); } _outline.AddLineTo(head.Pt2); _outline.AddClose(); _curvePath1 = null; _curvePath2 = null; _lastCurveTail = null; _lastPoint = new PointFP(control2); _drawingCurve = false; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * fill a round rectangle. * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax * @param ff_rx * @param ff_ry */ public void FillRoundRect(int ffXmin, int ffYmin, int ffXmax, int ffYmax, int ffRx, int ffRy) { FillPath(GraphicsPathFP.CreateRoundRect(ffXmin, ffYmin, ffXmax, ffYmax, ffRx, ffRy)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * fill a polygon. * @param points */ public void FillPolygon(PointFP[] points) { FillPath(GraphicsPathFP.CreatePolygon(points)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * fill closed curves. * @param points * @param offset * @param numberOfSegments * @param ff_factor */ public void FillClosedCurves(PointFP[] points, int offset, int numberOfSegments, int ffFactor) { FillPath(GraphicsPathFP.CreateSmoothCurves(points, offset, numberOfSegments, ffFactor, true)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw an arc. * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax * @param ff_startangle * @param ff_sweepangle */ public void DrawArc(int ffXmin, int ffYmin, int ffXmax, int ffYmax, int ffStartangle, int ffSweepangle) { DrawPath(GraphicsPathFP.CreateArc(ffXmin, ffYmin, ffXmax, ffYmax, ffStartangle, ffSweepangle, false)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw curves. * @param points * @param offset * @param numberOfSegments * @param ff_factor */ public void DrawCurves(PointFP[] points, int offset, int numberOfSegments, int ffFactor) { DrawPath(GraphicsPathFP.CreateSmoothCurves(points, offset, numberOfSegments, ffFactor, false)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Draw a polygon * @param points the coordinates of the polygon. */ public void DrawPolygon(PointFP[] points) { DrawPath(GraphicsPathFP.CreatePolygon(points)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a path. * @param path */ public void DrawPath(GraphicsPathFP path) { if (_lineStyle.DashArray != null) { var newlineStyle = new PenFP(_lineStyle.Brush, _lineStyle.Width, PenFP.LINECAP_BUTT, PenFP.LINECAP_BUTT, PenFP.LINEJOIN_MITER) {DashArray = _lineStyle.DashArray}; var dasher = new GraphicsPathDasherFP(path, newlineStyle.DashArray, 0); var newPath = dasher.GetDashedGraphicsPath(); _renderer.DrawPath(newPath.CalcOutline(newlineStyle), _matrix, _lineStyle.Brush, GraphicsPathRendererFP.MODE_ZERO); } else { _renderer.DrawPath(path.CalcOutline(_lineStyle), _matrix, _lineStyle.Brush, GraphicsPathRendererFP.MODE_ZERO); } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * draw a rectangle. * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax */ public void DrawRect(int ffXmin, int ffYmin, int ffXmax, int ffYmax) { DrawPath(GraphicsPathFP.CreateRect(ffXmin, ffYmin, ffXmax, ffYmax)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * fill a pie. * @param ff_xmin * @param ff_ymin * @param ff_xmax * @param ff_ymax * @param ff_startangle * @param ff_sweepangle */ public void FillPie(int ffXmin, int ffYmin, int ffXmax, int ffYmax, int ffStartangle, int ffSweepangle) { FillPath(GraphicsPathFP.CreateArc(ffXmin, ffYmin, ffXmax, ffYmax, ffStartangle, ffSweepangle, true)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Draw a line. * @param ff_x1 the x coord of the first point of the line. * @param ff_y1 the y coord of the first point of the line. * @param ff_x2 the x coord of the second point of the line. * @param ff_y2 the y coord of the second point of the line. */ public void DrawLine(int ffX1, int ffY1, int ffX2, int ffY2) { DrawPath(GraphicsPathFP.CreateLine(ffX1, ffY1, ffX2, ffY2)); }