Prowl.Quill includes a self-contained SVG pipeline composed of two static classes —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl.Quill/llms.txt
Use this file to discover all available pages before exploring further.
SVGParser and SVGRenderer — and a hierarchy of typed element classes rooted at SvgElement. SVGParser converts an SVG XML file on disk into an in-memory tree of SvgElement objects, each already pre-parsed for colours, stroke widths, and path commands. SVGRenderer walks that tree and issues the equivalent Canvas draw calls, applying strokes and fills with anti-aliasing. The pipeline supports the most common SVG primitives and is designed for embedding icons, illustrations, and other vector assets in Quill-rendered UIs.
SVGParser
SVGParser is a static class. It parses SVG XML files and returns the root
SvgElement of the document tree. Internally it uses System.Xml.XmlDocument
and maps each recognised XML element to a typed subclass.
Methods
ParseSVGDocument
<svg>, and
recursively parses all child elements into a typed SvgElement tree.
Absolute or relative path to the
.svg file.SvgElement (always of TagType.svg). Use
SvgElement.Flatten() to enumerate all descendants, or pass the root directly
to SVGRenderer.DrawToCanvas.
Exceptions:
FileNotFoundException— file does not exist at the given path.InvalidOperationException— document root is not an<svg>element.
Supported Element Types
The parser maps XML tag names to typed subclasses. Unsupported tags are silently skipped during tree construction.| SVG tag | C# class | Parsed fields |
|---|---|---|
<svg> | SvgElement | Container root |
<path> | SvgPathElement | d attribute → DrawCommand[] |
<circle> | SvgCircleElement | cx, cy, r |
<rect> | SvgRectElement | x, y, width, height, rx, ry |
<line> | SvgLineElement | x1, y1, x2, y2 |
<ellipse> | SvgEllipseElement | cx, cy, rx, ry |
<polyline> | SvgPolylineElement | points |
<polygon> | SvgPolygonElement | points |
<g> | SvgElement | Group container (children parsed recursively) |
SVGRenderer
SVGRenderer is a static class that translates a parsed SvgElement tree
into canvas draw calls. It calls SvgElement.Flatten() internally and
dispatches each element to the appropriate drawing function.
Static Fields
The colour substituted when an SVG element declares
stroke="currentColor" or
fill="currentColor". Defaults to Color.White. Set this before calling
DrawToCanvas to match the ambient UI colour:When
true, the renderer prints each processed draw command to
Console.WriteLine. Automatically reset to false at the end of each
DrawToCanvas call. Useful for diagnosing incorrect path rendering:Methods
DrawToCanvas
position. The method:
- Calls
svgElement.Flatten()to produce a depth-first ordered list of all descendants. - For each element, configures the canvas stroke colour, fill colour, and stroke width from the element’s parsed style properties.
- Dispatches to the element-type-specific draw function.
- Resets
debugtofalsebefore returning.
The target canvas. The canvas’s current transform, scissor, and global alpha
are respected. The SVG elements are drawn on top of any geometry already
accumulated in the frame.
A pixel-space offset added to all coordinates in the SVG. Use this to
position the SVG within the canvas without modifying the SVG’s internal
coordinate system.
The root element returned by
SVGParser.ParseSVGDocument. You can also pass
any subtree node to render only a portion of the document.SvgElement
SvgElement is the base class for all parsed SVG nodes. It stores common
presentation attributes (stroke, fill, stroke-width) and the hierarchical
structure (parent–child relationships). Specialised subclasses add
geometry-specific fields.
Fields
The element type, corresponding to the XML tag name. Possible values:
svg,
path, circle, rect, line, polyline, polygon, ellipse, g.Zero-based nesting depth in the original document. The root
<svg> element
has depth 0; direct children have depth 1, etc.All XML attributes defined on this element, keyed case-insensitively. Access
raw attribute values for properties not explicitly surfaced on subclasses.
Direct child elements. Recursively populated during parsing. Use
Flatten() to iterate the entire subtree in depth-first order.Path draw commands for
SvgPathElement instances. null on non-path
elements. Each DrawCommand stores the command type (DrawType), whether
coordinates are relative, and a float[] of parameters.The parsed stroke colour. Only valid when
strokeType == ColorType.specific.The parsed fill colour. Only valid when
fillType == ColorType.specific.Determines how the stroke colour is sourced:
none (no stroke), currentColor
(use SVGRenderer.currentColor), or specific (use stroke).Determines how the fill colour is sourced:
none (no fill), currentColor
(use SVGRenderer.currentColor), or specific (use fill).The stroke width in SVG user units. Defaults to
1.0 if the stroke-width
attribute is absent.Methods
Flatten
ToString
SvgPathElement overrides this to also list each DrawCommand.)
ColorType Enum
SvgElement.ColorType describes how a colour value is sourced for stroke or
fill.
| Value | Meaning |
|---|---|
none | No colour — the property is disabled (no stroke or no fill). |
currentColor | Inherit the colour from SVGRenderer.currentColor. |
specific | A concrete colour is defined in the SVG attribute. |
DrawCommand and DrawType
DrawCommand is a struct holding one parsed SVG path command. DrawType is the
corresponding enum.
| DrawType | SVG letter | Parameters |
|---|---|---|
MoveTo | M / m | x, y |
LineTo | L / l | x, y |
HorizontalLineTo | H / h | x |
VerticalLineTo | V / v | y |
CubicCurveTo | C / c | x1 y1 x2 y2 x y |
SmoothCubicCurveTo | S / s | x2 y2 x y |
QuadraticCurveTo | Q / q | x1 y1 x y |
SmoothQuadraticCurveTo | T / t | x y |
ArcTo | A / a | rx ry x-rot large-arc sweep x y |
ClosePath | Z / z | (none) |
DrawCommand.relative = true; uppercase set false.