Skip to main content
Glassen accepts a filled SVG path or a canvas alpha mask. Rust builds a signed distance field once; the field supplies both shading and hit testing during stretch.
createPathShape(path, options) accepts path data, not an SVG document. Defaults are viewBox: [0,0,100,100], padding: 0.12, resolution: 512 and fillRule: 'nonzero'. Use fillRule: 'evenodd' for a path with holes.

Canvas masks

The callback receives a cleared canvas with white fill. Alpha defines the filled area, so you can draw paths or text with native canvas APIs. Wait for fonts before drawing text. The mask must have a filled area and a transparent outer border. Resolution must be an integer from 16 to 1024. Share one shape object across lenses and retain it through context restoration. lens.update({ shape: null }) restores the default orb. Filtered shading normals reduce raster spikes, but a finite-resolution mask cannot reproduce arbitrarily thin features. Inspect corners, holes, minification and stretched silhouettes at the sizes you ship. Custom shapes use the same screen-space optical approximation; they are not solid meshes with modeled wall thickness. The web adapter supports these masks. The preserved Metal host does not yet bind custom fields; see porting.