private void AddLineCap(PointFP p1, PointFP p2, int lineCap) { if (lineCap == PenFP.LINECAP_BUTT || p1.Equals(p2)) { return; } var dx = p2.X - p1.X; var dy = p2.Y - p1.Y; var len = PointFP.Distance(dx, dy); var cap = lineCap == PenFP.LINECAP_ROUND ? GraphicsPathFP.ROUNDCAP : GraphicsPathFP.SQUARECAP; dx = MathFP.Mul(_ffRad, MathFP.Div(dx, len)); dy = MathFP.Mul(_ffRad, MathFP.Div(dy, len)); var m = new MatrixFP(dx, dx, dy, -dy, p2.X, p2.Y); _outline.AddMoveTo(new PointFP(0, GraphicsPathFP.ONE).Transform(m)); for (var 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(); }
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()); var needLineJoin = false; var pi1 = new PointFP(); var pi2 = new PointFP(); var cross1 = LineFP.Intersects(new LineFP(head.Pt1, tail.Pt1), new LineFP(lastHead.Pt1, lastTail.Pt1), pi1); var cross2 = LineFP.Intersects(new LineFP(head.Pt2, tail.Pt2), new LineFP(lastHead.Pt2, lastTail.Pt2), pi2); if (cross1 && !cross2 && pi1.X != SingleFP.NOT_A_NUMBER) { p1 = lastTail.Pt2; p2 = head.Pt2; needLineJoin = true; } else if (!cross1 && cross2 && pi2.X != SingleFP.NOT_A_NUMBER) { p1 = lastTail.Pt1; p2 = head.Pt1; 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); } } }
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.Pt1); _curvePath2.AddLineTo(_lastCurveTail.Pt2); } _lastCurveTail = new LineFP(tail); } else { if (_needDrawStartCap) { _startCapP1 = new PointFP(_currPoint); _startCapP2 = new PointFP(point); _needDrawStartCap = false; } AddLineJoin(_lastPoint, _currPoint, point); _outline.AddMoveTo(head.Pt1); _outline.AddLineTo(tail.Pt1); _outline.AddLineTo(tail.Pt2); _outline.AddLineTo(head.Pt2); _outline.AddLineTo(head.Pt1); _outline.AddClose(); _lastPoint = new PointFP(_currPoint); } base.LineTo(point); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 13JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Check to see if the point is empty one. * @param p * @return */ public static bool IsEmpty(PointFP p) { return(Empty.Equals(p)); }