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.
Canvas3D wraps a Canvas and adds a full 3D projection pipeline — world, view, and projection matrices — so that 3D coordinates can be projected to the 2D screen and rendered with the same anti-aliased stroke and fill primitives that Prowl.Quill provides. It supports a path API that mirrors the 2D canvas (MoveTo, LineTo, ClosePath, Stroke, Fill) but accepts Float3 coordinates, as well as convenience methods for wireframe cubes, spheres, arcs, and Bézier curves in 3D space.
Constructor
Canvas3D wrapping an existing Canvas. All three matrices start
as the identity matrix. The canvas is not owned by Canvas3D — dispose the
underlying Canvas separately when done.
The 2D canvas that receives projected draw calls. Must not be null.
Width of the virtual viewport in logical units. Pass
0 (default) to use
canvas.Width dynamically each frame — useful when the window is resizable.Height of the virtual viewport in logical units. Pass
0 (default) to use
canvas.Height dynamically.Properties
The underlying 2D canvas. Use this to set stroke/fill colours, widths, and any
other 2D canvas state before drawing 3D geometry.
The camera view matrix. Setting this property recomputes the combined
view-projection matrix (
Projection × View × World) immediately. Use
SetLookAt as a convenience helper to construct and apply a look-at view
matrix.The projection matrix (perspective or orthographic). Setting this property
recomputes the combined matrix. Use
SetPerspectiveProjection to construct
and apply a standard perspective frustum.The world transform applied to every 3D point before the view and projection
transforms. Setting this property recomputes the combined matrix. Use
SetWorldTransform to compose a TRS (translate–rotate–scale) world matrix.Width of the viewport used for NDC-to-screen conversion. Returns
canvas.Width when the stored value is ≤ 0, making it automatically follow a
resizable window. Set explicitly to render into a sub-region of the canvas.Height of the viewport used for NDC-to-screen conversion. Returns
canvas.Height when the stored value is ≤ 0.Matrix Setup Helpers
SetPerspectiveProjection
Vertical field-of-view angle in radians. A value of
MathF.PI / 4
(45°) is a common starting point.Viewport width divided by height (
ViewportWidth / ViewportHeight).Distance to the near clipping plane. Must be positive. Typical value:
0.1.Distance to the far clipping plane. Typical value:
100 to 1000.SetLookAt
cameraPosition, pointing toward targetPosition, with upVector defining
the camera’s up direction.
Position of the camera in world space.
Point in world space the camera looks at.
World-space up direction. Typically
Float3.UnitY.SetWorldTransform
WorldMatrix. The composition order is Scale × Rotation × Translation.
World-space translation.
Object rotation. Build with
Quaternion.FromEuler or similar.Per-axis scale. Use
Float3.One for no scaling.Projection Utilities
Project
Float2. Returns (NaN, NaN) when the point is
behind the camera or outside the view frustum — always check float.IsNaN
before using the result.
IsVisible
true if the point is within the view frustum (clip-space W > 0 and
all NDC coordinates in [-1, 1]).
DrawLine
Start point in world space.
End point in world space.
Stroke colour.
Stroke width in logical units. Default
1.0.3D Path API
Canvas3D provides a path API that accumulates 3D points and projects them to
2D when Stroke() or Fill() is called. Points that project outside the
frustum are dropped from the path; the renderer starts a new sub-path segment
when it encounters the next visible point.
BeginPath
MoveTo
LineTo
ClosePath
Stroke
Canvas path, and calls Canvas.Stroke(). Uses the canvas’s current stroke
colour, width, joint, and cap settings. Does nothing if the path contains fewer
than two points.
Fill
Canvas.Fill(). Uses the
canvas’s current fill colour and winding mode.
Primitive Drawing Methods
DrawCubeStroked
center with equal side lengths of size.
Each of the twelve edges is stroked as a separate path. Uses the current canvas
stroke colour and width.
Centre of the cube in local (world) space.
Total edge length. Half-size
size/2 is applied in each direction.DrawSphereStroked
Centre of the sphere in world space.
Sphere radius.
Number of segments per ring and number of rings. Default
16.Arc
normal, starts along startDir, and sweeps through
angleInRadians. Call Stroke() or Fill() after to render it.
Centre point of the arc.
Arc radius.
Normal vector of the plane containing the arc. Normalised internally.
Direction from
center to the arc’s first point. Normalised internally.Total sweep angle in radians. Use
MathF.PI * 2 for a full circle.Number of line segments approximating the arc. Default
16.BezierCurve
segments uniformly spaced parameter values and calls
LineTo for each point. Call Stroke() after to render.
Start point (anchor).
First control point.
Second control point.
End point (anchor).
Number of line segments. Default
16.Demo Method
Demo3D
(0, 0, −10) toward the origin, then draws:
- A rotating wireframe cube offset left at
(−3, 0, 0), stroked in red. - A rotating wireframe sphere offset right at
(3, 0, 0), stroked in blue. - A full-circle arc in the XZ plane at the origin, filled yellow and stroked purple with a heavier stroke width.
Environment.TickCount, so the scene animates when
called repeatedly each frame.
Complete Example: 3D Wireframe Scene
The following example sets up a perspective camera and draws a rotating wireframe cube, a wireframe sphere, and a full-circle arc — the same scene used in the library’s built-inDemo3D method.