public void DrawPath(AbstractPen pen, AbstractBrush brush, AbstractPath path) { var e = Append(new Element(ElementNames.PATH)); e.Set("d", ToSVG(path)); e.Apply(pen, brush); }
private static string ToSVG(AbstractPath ap) { PathBuilder path = new PathBuilder(); for (int i = 0; i < ap.Points.Length; ++i) { byte type = ap.Types[i]; PointF point = ap.Points[i]; switch (type & 0x7) { case 0: path.MoveTo(point.X, point.Y); break; case 1: path.LineTo(point.X, point.Y); break; case 3: throw new ApplicationException("Unsupported path point type: " + type); } if ((type & 0x20) != 0) { throw new ApplicationException("Unsupported path flag type: " + type); } if ((type & 0x80) != 0) { path.Close(); } } return(path.ToString()); }
public static RectangleF Bounds(AbstractPath path) { RectangleF rect = new RectangleF(); PointF[] points = path.Points; rect.X = points[0].X; rect.Y = points[0].Y; for (int i = 1; i < points.Length; ++i) { PointF pt = points[i]; if (pt.X < rect.X) { float d = rect.X - pt.X; rect.X = pt.X; rect.Width += d; } if (pt.Y < rect.Y) { float d = rect.Y - pt.Y; rect.Y = pt.Y; rect.Height += d; } if (pt.X > rect.Right) rect.Width = pt.X - rect.X; if (pt.Y > rect.Bottom) rect.Height = pt.Y - rect.Y; } return rect; }
public void IntersectClip(AbstractPath path) { var clipPath = AddDefinition(new Element(ElementNames.CLIPPATH)); var p = clipPath.Append(new Element(ElementNames.PATH)); p.Set("d", ToSVG(path)); var e = Open(new Element(ElementNames.G)); e.Set("clip-path", $"url(#{clipPath.Get("id")})"); }
public void DrawPath(AbstractPen pen, AbstractPath path) { DrawPath(pen, null, path); }
public void DrawPath(AbstractBrush brush, AbstractPath path) { DrawPath(null, brush, path); }
public void IntersectClip(AbstractPath path) { g.IntersectClip(new Region(new GraphicsPath(path.Points, path.Types, FillMode.Winding))); }
public void DrawPath(AbstractBrush brush, AbstractPath path) { Apply(brush); g.FillPath(this.brush, new GraphicsPath(path.Points, path.Types, FillMode.Winding)); }
public void DrawPath(AbstractPen pen, AbstractPath path) { Apply(pen); g.DrawPath(this.pen, new GraphicsPath(path.Points, path.Types, FillMode.Winding)); }