private static ControlPointCollection DrawPoints(IGlyphRenderer surface, ControlPointCollection points, Vector2 point) { switch (points.Count) { case 0: break; case 1: surface.QuadraticBezierTo( points.SecondControlPoint, point); break; case 2: surface.CubicBezierTo( points.SecondControlPoint, points.ThirdControlPoint, point); break; default: throw new NotSupportedException("Too many control points"); } points.Clear(); return(points); }
public void OriginUsed() { // Y axis is inverted as it expects to be drawing for bottom left GlyphBuilder fullBuilder = new GlyphBuilder(new System.Numerics.Vector2(10, 99)); IGlyphRenderer builder = fullBuilder; builder.BeginGlyph(Vector2.Zero); builder.BeginFigure(); builder.MoveTo(new Vector2(0, 0)); builder.LineTo(new Vector2(0, 10)); // becomes 0, -10 builder.CubicBezierTo( new Vector2(15, 15), // control point - will not be in the final point collection new Vector2(15, 10), // control point - will not be in the final point collection new Vector2(10, 10)); // becomes 10, -10 builder.QuadraticBezierTo( new Vector2(10, 5), // control point - will not be in the final point collection new Vector2(10, 0)); builder.EndFigure(); builder.EndGlyph(); System.Collections.Immutable.ImmutableArray <Vector2> points = fullBuilder.Paths.Single().Flatten().Single().Points; Assert.Contains(new Vector2(10, 99), points); Assert.Contains(new Vector2(10, 109), points); Assert.Contains(new Vector2(20, 99), points); Assert.Contains(new Vector2(20, 109), points); }