API
Types
The option objects, event maps and uniform types the classes are built from. All are exported from blotter.ts for your own annotations.
On this page
TextProperties interface
The styles a Text is drawn with. Every field is optional on construction.
- family
- Any CSS font-family list. Default
"sans-serif". - size
- Font size in pixels. Default
12. - leading
- Line height as a unitless multiplier, or a string in px or %. Default
1.5; keep it above 1. - fill
- Text colour. Default
"#000". - style
"normal"or"italic". Default"normal".- weight
- A number or string, as in CSS. Default
400. - padding
- Space around the text in pixels, on every side. Default
0. - paddingTop
- Per-side override.
- paddingRight
- Per-side override.
- paddingBottom
- Per-side override.
- paddingLeft
- Per-side override.
TextEvents type
The events a Text emits: update, whenever its value or properties change.
TextBounds interface
A rectangle in the atlas: x, y, width and height in pixels.
RenderScopeEvents type
The events a RenderScope emits: ready, update and render for this text, plus the pointer events with a normalised position.
BlotterEvents type
The events a Blotter emits: ready after the first build, update after later rebuilds, render every frame with the frame count.
BlotterOptions interface
Options for the Blotter constructor.
- texts
- A text or an array of texts to draw.
- ratio
- Pixel ratio for every output canvas. Default: the device pixel ratio.
- autobuild
- Build on construction and after changes. Default
true. - autostart
- Start the render loop immediately. Default
true. - autoplay
- New render scopes start playing. Default
true.
UniformType type
The four GLSL vector sizes a uniform can have.
Vec2 type
A two-number tuple.
Vec3 type
A three-number tuple.
Vec4 type
A four-number tuple.
UniformValueMap interface
The value shape for each UniformType: a number for "1f", a tuple otherwise.
UniformDescriptor type
What you write when declaring a uniform: a type and a matching initial value.
type UniformDescriptor =
| { type: "1f"; value: number }
| { type: "2f"; value: Vec2 }
| { type: "3f"; value: Vec3 }
| { type: "4f"; value: Vec4 } UniformMap type
Uniform descriptors keyed by name, as passed to a material.
UniformInterfaceMap type
Live UniformInterface handles keyed by name, as read from material.uniforms.
MaterialEvents type
The events a Material emits: update when the shader or uniform set changes, and update:uniform with the name of a uniform whose value changed.
MaterialOptions interface
Options for the Material constructor.
- mainImage
- The GLSL body. Omit for the passthrough.
- uniforms
- Uniform declarations by name.