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 is a lightweight wrapper around the standard Canvas that adds a full perspective-projection pipeline. Instead of thinking in screen pixels, you define 3D scene geometry — vertices, paths, curves — and Canvas3D projects them to 2D canvas coordinates automatically. The underlying Canvas handles all antialiasing, stroke styles, and fill, so every 2D drawing API you already know continues to work; Canvas3D simply replaces the coordinate system.
Constructor
Canvas you render into. The optional viewportWidth / viewportHeight parameters set the screen-space region used when converting NDC to pixel coordinates. When both are left at 0 (the default), Canvas3D automatically reads canvas.Width and canvas.Height each frame.
Properties
Canvas
Canvas Canvas { get; } — the underlying 2D canvas being wrapped. Use it directly for stroke colours, fill, state save/restore, etc.ViewMatrix
Float4x4 ViewMatrix { get; set; } — camera-space transform. Setting it automatically recomputes the combined view-projection matrix.ProjectionMatrix
Float4x4 ProjectionMatrix { get; set; } — perspective or orthographic projection. Recomputes combined matrix on assignment.WorldMatrix
Float4x4 WorldMatrix { get; set; } — object-to-world transform. Setting it recomputes the combined matrix.Viewport dimensions
0. Override them to render into a sub-region of the canvas — for example, a panel inside a UI:
Setting up the camera
Perspective projection
Float4x4.CreatePerspectiveFov and assigns ProjectionMatrix.
Look-at camera
Float4x4.CreateLookAt and assigns ViewMatrix.
World transform
scale → rotation → translation into WorldMatrix:
Projecting 3D points
point3D through the combined view-projection matrix, performs perspective division, and maps to viewport coordinates. Returns Float2(NaN, NaN) when the point is behind the camera or outside the view frustum.
true only when the point would produce valid screen coordinates.
3D path API
Canvas3D exposes its own BeginPath / MoveTo / LineTo / ClosePath / Stroke / Fill that accumulate 3D points, project them, and flush to the underlying canvas:
Direct line helper
Primitive helpers
| Method | Description |
|---|---|
DrawCubeStroked(Float3 center, float size) | Wireframe cube: 12 edges, 8 projected vertices |
DrawSphereStroked(Float3 center, float radius, int segments = 16) | Latitude + longitude wireframe rings |
Arc(Float3 center, float radius, Float3 normal, Float3 startDir, float angleInRadians, int segments = 16) | 3D arc in a plane defined by normal |
BezierCurve(Float3 p0, Float3 p1, Float3 p2, Float3 p3, int segments = 16) | Cubic Bézier through projected line segments |
Complete setup example
Create Canvas3D
Wrap your existing canvas with
Canvas3D. The constructor takes an optional viewport size; leaving it at zero uses the canvas dimensions automatically.Set projection and camera
Configure the perspective projection and camera position each frame (or whenever the window resizes).
Configure the world transform and draw
For each object, set a world transform and then use the 3D path or primitive API. Use the underlying
Canvas to set stroke colour, width, and fill colour as usual.Always apply your canvas transform (e.g.
canvas.TransformBy(Transform2D.CreateTranslation(x, y))) before drawing with Canvas3D. The 3D projection produces 2D viewport coordinates that are relative to the canvas origin, so the current 2D transform controls where in the window the scene appears.