/// <summary> /// Writes the specified PolyQuadraticBezierSegment to the content stream. /// </summary> internal void WriteSegment(PolyQuadraticBezierSegment seg) { if (!DevHelper.FlattenPolyQuadraticBezierSegment) { int count = seg.Points.Count; PointStopCollection points = seg.Points; Point pt0 = this.currentPoint; for (int idx = 0; idx < count - 1;) { Point pt1 = points[idx++]; Point pt2 = points[idx++]; // Cannot believe it: I just guessed the formula and it works! WriteLiteral("{0:0.####} {1:0.####} {2:0.####} {3:0.####} {4:0.####} {5:0.####} c\n", pt1.X - (pt1.X - pt0.X) / 3, pt1.Y - (pt1.Y - pt0.Y) / 3, pt1.X + (pt2.X - pt1.X) / 3, pt1.Y + (pt2.Y - pt1.Y) / 3, pt2.X, pt2.Y); this.currentPoint = pt0 = pt2; } } else { PolyLineSegment lseg = WpfUtils.FlattenSegment(this.currentPoint, seg); WriteSegment(lseg); } }
/// <summary> /// Writes the specified PolyBezierSegment to the content stream. /// </summary> internal void WriteSegment(PolyBezierSegment seg) { int count = seg.Points.Count; PointStopCollection points = seg.Points; for (int idx = 0; idx < count - 2; idx += 3) { WriteLiteral("{0:0.###} {1:0.###} {2:0.###} {3:0.###} {4:0.###} {5:0.###} c\n", points[idx].X, points[idx].Y, points[idx + 1].X, points[idx + 1].Y, points[idx + 2].X, points[idx + 2].Y); this.currentPoint = points[idx + 2]; } }
/// <summary> /// Parses a series of points. /// </summary> internal static PointStopCollection ParsePoints(string value) { PointStopCollection points = new PointStopCollection(); TokenizerHelper tokenizer = new TokenizerHelper(value); while (tokenizer.NextToken()) { Point point = new Point(ParserHelper.ParseDouble(tokenizer.GetCurrentToken()), ParserHelper.ParseDouble(tokenizer.NextTokenRequired())); points.Add(point); } return points; }