PeachDrawing.Core
PeachDrawing.Core
GraphicsPath Class
Adapter for platform specific graphics path object - used to render (draw/fill) path shape.
public abstract class GraphicsPath : System.IDisposable
Inheritance System.Object → GraphicsPath
Implements System.IDisposable
Remarks
The recorder methods (Start(double, double)/LineTo(double, double)/ArcTo(double, double, double, double, Corner)/
AddMove(double, double)/AddBezierTo(double, double, double, double, double, double)/AddArc(double, double, double, double, double, bool, bool)/CloseFigure()) are
virtual, not abstract: the base implementation also records a concrete, backend-agnostic
segment list (every arc converted to an equivalent cubic Bézier at record time, the same way a
concrete backend’s own native path representation typically does - see Transform(Matrix3x2)’s own
remarks on why that makes an affine transform exact regardless of which segment type it touches), so
Flatten(double) works for any subclass without that subclass doing anything extra. A concrete
override still does its own native-representation work and must call the base method too (e.g.
base.Start(x, y)) to keep the shared segment list in sync.
| Properties | |
|---|---|
| FillMode | Gets or sets how the interior of a self-intersecting path is determined for filling. |
| Methods | |
|---|---|
| AddArc(double, double, double, double, double, bool, bool) | Add an elliptical arc (SVG-style parameterization) from the last point to the given end point. |
| AddBezierTo(double, double, double, double, double, double) | Add a cubic Bezier curve from the last point through the two given control points to the given end point. |
| AddMove(double, double) | Start a new subpath at the given point without connecting it to the previous subpath (unlike Start(double, double), which only remembers the point and lets the next LineTo(double, double)/AddBezierTo(double, double, double, double, double, double)/AddArc(double, double, double, double, double, bool, bool) call implicitly connect to it if a subpath is already open). Needed for paths with multiple disjoint subpaths, e.g. an SVG d attribute with more than one M command, or a clip region built from several shapes in one path. |
| AddPath(GraphicsPath) | Appends path’s geometry as one or more disjoint subpaths (a union, not a connected continuation). Used to merge an individually-transformed clip shape into the combined clip region. |
| ArcTo(double, double, double, double, Corner) | Add elliptical arc with separate horizontal and vertical radii to the given point. |
| ArcTo(double, double, double, Corner) | Add circular arc of the given size to the given point from the last point. |
| ClipToRect(Rect) | Returns a new path holding this path’s own filled area (per its own FillMode) intersected with the axis-aligned rectangle rect - the geometric equivalent of the clip PushClip(Rect)/PopClip() would apply around this path at paint time, but expressed as path geometry a caller can union into a larger clip shape instead (see FragmentPainter.Decorations.cs’s CollectUprightWord, which needs each upright character’s own glyph outline confined to its own reserved cell - the same cell PaintUprightVerticalRun already clips *painting* to for a font with real vertical metrics - before the outline is added to the background-clip: text union). |
| CloseFigure() | Marks the current contour closed - connecting its end back to its start, per CloseFigure(). |
| Dispose() | Release path resources. |
| Flatten(double) | Flattens this path’s recorded geometry (independent of whatever native representation a concrete subclass also builds) into polylines within tolerance of the true curve, one PathContour per subpath. Lets any Canvas backend - the raster backend, or a third party’s own - read this path’s geometry without knowing which concrete GraphicsPath built it. |
| GetCurveContours() | Reads this path’s recorded geometry with its curves intact: one CurveContour per subpath, made of lines and cubic Béziers (every arc already converted to cubics at record time). Like Flatten(double) it is independent of whatever native representation a concrete subclass also builds, and it returns a snapshot: later edits to the path do not change a list already returned. This is what geometry that must stay curved - measuring a path’s length, or combining two paths - reads instead of the flattened polylines. |
| LineTo(double, double) | Add straight line to the given point from the last point. |
| Start(double, double) | Start path at the given point. |
| Transform(Matrix3x2) | Applies an affine transform to every point already added to the path. Because the concrete path stores arcs as Bézier segments (which are closed under affine transforms), this is an exact transform of the whole geometry for any matrix - translate, scale, rotate or skew. Used to bake a clip shape’s own transform into its geometry, since a clip region is built as a single path and cannot use the graphics-state transform (which would apply to the whole clip rather than one contributing shape). |