Prowl.Quill includes a built-in SVG pipeline that parses a subset of the SVG specification into anDocumentation 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.
SvgElement tree and then walks that tree to emit draw calls onto any Canvas. Because the renderer translates every SVG element into the same path and primitive APIs you use directly, SVG shapes benefit from the same hardware-accelerated anti-aliasing and stroke styling as hand-coded drawings.
Supported Elements
| SVG Element | Class | Notes |
|---|---|---|
<path> | SvgPathElement | Full d attribute with M/L/H/V/C/S/Q/T/A/Z commands, relative and absolute |
<circle> | SvgCircleElement | cx, cy, r |
<rect> | SvgRectElement | x, y, width, height, rx, ry (rounded corners) |
<line> | SvgLineElement | x1, y1, x2, y2 |
<ellipse> | SvgEllipseElement | cx, cy, rx, ry |
<polyline> | SvgPolylineElement | points (open path) |
<polygon> | SvgPolygonElement | points (closed path) |
<g> / <svg> | SvgElement | Parsed as containers; children are flattened for rendering |
SVGParser
SVGParser is a static class with a single public method that reads an SVG XML file from disk and returns the root SvgElement.
- Loads the XML document via
XmlDocument. - Walks the element tree recursively, creating the appropriate typed subclass for each tag.
- Calls
element.Parse()on each node to resolvefill,stroke,stroke-width, and element-specific geometry attributes. - Throws
FileNotFoundExceptionif the path does not exist, orInvalidOperationExceptionif the root element is not<svg>.
SVGParser.ParseSVGDocument reads the file synchronously. For large SVG assets, parse once at load time and cache the returned SvgElement tree — do not call this method every frame.SvgElement Tree
Each node in the parsed tree is an SvgElement or one of its typed subclasses. The key properties you will interact with are:
SvgElement.Flatten() recursively collects the element and all its descendants into a single List<SvgElement> — this is what SVGRenderer.DrawToCanvas uses internally.
SVGRenderer
SVGRenderer is a static class with two public configuration fields and one drawing method.
currentColor
The Color32 used whenever an SVG element specifies fill="currentColor" or stroke="currentColor". Set this before calling DrawToCanvas to control the inherited colour.
debug
When set to true, DrawToCanvas prints each processed draw command to Console.WriteLine. The flag is automatically reset to false after DrawToCanvas returns.
DrawToCanvas
Flattens the SvgElement tree and emits the corresponding canvas draw calls at the specified position offset.
| Parameter | Description |
|---|---|
canvas | The target Canvas instance |
position | World-space offset applied to all element coordinates |
svgElement | The root element returned by SVGParser.ParseSVGDocument |
- Calls
canvas.SetStrokeColor/canvas.SetFillColor(orcurrentColorforcurrentColorattributes). - Calls
canvas.SetStrokeWidthwith the element’sstrokeWidth. - Builds the geometry (path commands, circle, rect, etc.) using the canvas path API.
- Calls
FillComplexAA()for filled elements andStroke()for stroked elements.
Complete Example
Animating SVG with Canvas Transforms
BecauseDrawToCanvas uses the canvas path API, any canvas transform active at call time is applied to all SVG geometry. This makes rotation, scaling, and translation trivial:
Inspecting the Element Tree
Limitations and Notes
No CSS / Style Sheets
Only inline
fill, stroke, and stroke-width XML attributes are parsed. External or <style> block CSS is not supported.No Gradients or Patterns
SVG
<linearGradient>, <radialGradient>, and <pattern> elements are not rendered. Use Quill’s native brush API for gradients.No Transforms on Elements
The SVG
transform attribute on individual elements is not applied. Apply transforms via the canvas state instead.currentColor Requires Manual Setting
Set
SVGRenderer.currentColor before each DrawToCanvas call. It is a static field shared across all concurrent uses.