Expand description
Mapping user space onto clip space.
Three coordinate systems meet here, and confusing any two of them produces output that is mirrored or off by a scale factor rather than obviously broken:
- Path space — whatever units a path was authored in.
- Device space — pixels on the target. Origin top-left, X right, Y down, which is the convention 2D UI works in.
- Clip space — what the vertex shader emits. Both axes in
[-1, 1], and Y runs up, following the WGSL convention that shader translation normalizes to. This is the axis that flips.
Tolerance is a device-space quantity, so flattening a path that will be
scaled up has to happen more finely in path space. max_scale is what
that adjustment is computed from.
Structs§
- Transform2D
- A transform of the plane that may carry perspective.
Functions§
- invert_
to_ local - Invert a paint’s placement into the form a shader’s
to_localtakes. - max_
scale - The largest factor by which a transform can stretch a direction.
- preserves_
axis_ alignment - Whether a transform maps axis-aligned rectangles to axis-aligned rectangles.
- to_
local_ columns - The same packing, for a mapping already stated in the direction the shader reads it.
- transform_
points - Apply a transform to every point in place.
- transformed_
bounds - The bounds of a rectangle’s corners after a transform, if there are any.
- unbounded
- Bounds standing in for “anywhere”, where a mapping gives none.
- viewport_
projection - Map device pixels onto clip space for a target of the given size.