drawing
Vector drawing primitives: paths, fills, strokes, caps, and gradients.
Submodules
Structs
Depth
Logical scene depth for lighting calculations.
Depth is expressed in logical pixels. Unlike [Size], it is not anchored
to a viewport or parent box, so percent and combined units are intentionally
rejected during value coercion.
Properties
0
Type: Numeric
Implementations
to_float
pub fn to_float(&self) -> f64
Returns the depth as a floating-point logical pixel value.
GradientStop
A color stop for a gradient fill, defined by a position (% or px) and a color.
Properties
position
Type: Size
Stop position, conventionally expressed as a percentage along the gradient.
color
Type: Color
Color at this stop.
Implementations
get
pub fn get(color: Color, position: Size) -> GradientStop
Constructs a gradient stop at position.
with_alpha_factor
pub fn with_alpha_factor(&self, factor: f64) -> GradientStop
Returns a copy of this stop with alpha multiplied by factor.
LinearGradient
Describes a linear gradient fill with a start and end point, and a list of color stops.
Pax templates canonically author each point as [x, y]: magic index 0
is the horizontal coordinate and index 1 is the vertical coordinate.
Properties
start
Gradient start point in the primitive's local coordinate space.
end
Gradient end point in the primitive's local coordinate space.
stops
Type: Vec<GradientStop>
Ordered color stops along the gradient.
MaterialParams
Tunable response parameters for a light-reactive vector material.
Properties
ambient
Type: Property<f64>
Ambient contribution multiplier.
diffuse
Type: Property<f64>
Diffuse contribution multiplier.
specular
Type: Property<f64>
Specular contribution multiplier.
roughness
Type: Property<f64>
Surface roughness in the [0.0, 1.0] range.
metallic
Type: Property<f64>
Metallic response in the [0.0, 1.0] range.
emissive
Additive emissive color.
emissive_intensity
Type: Property<f64>
Additive emissive intensity.
RadialGradient
Describes a radial gradient fill with a start and end point, a radius, and a list of color stops.
Pax templates canonically author each point as [x, y]: magic index 0
is the horizontal coordinate and index 1 is the vertical coordinate.
Properties
end
Outer radius endpoint in the primitive's local coordinate space.
start
Gradient center point in the primitive's local coordinate space.
radius
Type: f64
Radial gradient radius.
stops
Type: Vec<GradientStop>
Ordered color stops along the gradient.
SceneAmbientLight
Resolved ambient light for one logical canvas layer.
Properties
color
Type: Color
Ambient color.
intensity
Type: f64
Ambient intensity.
SceneLight
Resolved light contribution for one logical canvas layer.
Properties
shape
Type: LightShape
Positional or directional light shape.
position
Type: Vector3
Position in logical canvas pixels for point lights.
direction
Type: Vector3
Direction in scene space for directional lights.
color
Type: Color
Light color.
intensity
Type: f64
Light intensity.
radius
Type: f64
Point light radius in logical pixels.
enabled
Type: bool
Whether this light contributes.
SceneLighting
Resolved lighting state for one logical canvas layer.
Properties
active
Type: bool
Whether authored lights or ambient overrides are present.
ambient_is_authored
Type: bool
Whether ambient came from an enabled authored AmbientLight.
The default ambient is only applied to primitives with at least one eligible direct light. An authored ambient remains layer-wide.
ambient
Type: SceneAmbientLight
Singleton ambient contribution.
lights
Type: Vec<SceneLight>
Positional and directional light contributions.
Implementations
DEFAULT_AMBIENT_INTENSITY
Ambient intensity used when point/directional lights exist but no explicit ambient override exists.
MAX_LIGHTS
Maximum number of simultaneously enabled lights in one target canvas layer.
identity
pub fn identity() -> Self
Returns lighting that preserves unlit legacy rendering.
with_default_ambient
pub fn with_default_ambient(lights: Vec<SceneLight>) -> Self
Creates active lighting with Pax's default ambient term.
Stroke
Describes the outline drawn around vector geometry.
Pax currently renders strokes centered on the underlying path. For open
geometry, cap controls how the stroke terminates at the start and end of
the path, while join controls how adjacent segments meet.
Properties
color
The stroke color, including alpha.
width
The stroke width.
The type is [Size] for consistency with the wider property system, but
current vector renderers interpret this value in pixels.
cap
The cap style used for exposed endpoints on open paths.
join
Type: Property<StrokeJoin>
The join style used where adjacent stroke segments meet.
Vector3
A three-dimensional vector in logical scene space.
Properties
x
Type: f64
X component.
y
Type: f64
Y component.
z
Type: f64
Z component.
Implementations
new
pub fn new(x: f64, y: f64, z: f64) -> Self
Constructs a 3D vector.
Enums
Fill
Describes how to fill vector geometry.
Variants
Solid(Color)
A single solid color.
LinearGradient(LinearGradient)
A linear gradient.
RadialGradient(RadialGradient)
A radial gradient.
Implementations
coverage_alpha_0_1
pub fn coverage_alpha_0_1(&self) -> f64
Estimates the alpha coverage contributed by this fill.
linearGradient
pub fn linearGradient(start: (Size, Size), end: (Size, Size), stops: Vec<GradientStop>) -> Fill
Constructs a linear gradient fill.
Pax templates should normally use @gradient. When this helper is
needed explicitly, pass start and end as [x, y] lists.
max_alpha_0_1
pub fn max_alpha_0_1(&self) -> f64
Returns the maximum alpha used by this fill.
with_alpha_factor
pub fn with_alpha_factor(&self, factor: f64) -> Fill
Returns a copy of this fill with alpha multiplied by factor.
LightShape
Shape of a light contribution in logical scene space.
Variants
Point
A positional light with radius-based attenuation.
Directional
A light with direction but no position or attenuation.
Material
Light-reactive surface response for vector primitives.
This is intentionally named Material; texture is reserved for future
bitmap-backed texture maps and pattern data.
Variants
Lit(MaterialParams)
Responds to scene lighting using parameterized material coefficients.
Unlit
Ignores scene lighting and preserves legacy unlit rendering behavior.
Implementations
custom
pub fn custom(params: MaterialParams) -> Self
Creates a lit material from explicit coefficients.
emissive
pub fn emissive(color: Color, intensity: f64) -> Self
An emissive material that adds color independent of lights.
glossy
pub fn glossy(specular: f64) -> Self
A higher-specular material with lower roughness.
matte
pub fn matte() -> Self
A soft, low-specular material suitable as the default lit response.
metallic
pub fn metallic(metallic: f64) -> Self
A metallic material response.
unlit
pub fn unlit() -> Self
A material that ignores authored lights.
NavigationTarget
Describes where to open new windows or tabs when navigating to a URL from a Link node.
Variants
Current
Navigate in the current window or tab.
New
Navigate in a new window or tab.
PathElement
Describes a single element of a vector path, such as a line, a point, or curve segment.
Variants
Empty
No-op path element.
Point(Size, Size)
Moves the current point to the provided coordinate.
Line
Draws a straight line to the following Point.
Quadratic(Size, Size)
Draws a quadratic Bézier segment with one control point, ending at the following Point.
Cubic(Size, Size, Size, Size)
Draws a cubic Bézier segment with two control points, ending at the following Point.
Close
Closes the current contour.
PathSmoothing
Controls optional curve smoothing for path geometry before tessellation.
PathSmoothing is intended for authored or imported paths whose source data
approximates curves with many short line segments, such as single-stroke SVG
fonts. Existing paths keep their exact geometry by default.
Variants
None
Preserve the authored path exactly.
Light
Lightly smooth polyline runs while preserving sharp corners.
Strong
More aggressively smooth polyline runs for pen-like paths.
StrokeCap
Controls how an open stroke terminates at the exposed endpoints of a path.
StrokeCap affects primitives such as Line and open Path subpaths.
Closed geometry ignores cap style because it has no exposed endpoints.
Variants
Butt
Ends exactly at the path endpoint without extending past it.
Round
Adds a semicircular cap whose radius is half the stroke width.
Square
Adds a square cap that extends half the stroke width past the endpoint.
StrokeJoin
Controls how stroke segments are joined at path vertices.
Variants
Miter
Extends outer edges to a point, subject to the renderer's miter limit.
Round
Rounds the outside of each join.
Bevel
Cuts joins off with a straight edge.