Sprites in tiny-engine support a set of CSS-inspired visual filters applied directly as props on theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/tiny-engine/llms.txt
Use this file to discover all available pages before exploring further.
<sprite> node. Each filter maps to a canvas rendering operation executed every frame during the sprite’s draw call — no extra nodes or post-processing passes required.
Filter props
| Prop | Type | Range | Description |
|---|---|---|---|
brightness | number | 0 – 2+ | 0 renders the sprite black, 1 is the original appearance, 2 approaches white. |
grayscale | number | 0 – 1 | 0 leaves colours unchanged, 1 converts the sprite fully to grayscale. |
modulate | Color | RGBA 0–1 | Tints the sprite using canvas globalCompositeOperation: 'multiply'. See modulate behaviour below. |
contrast | number | 0 – 2+ | 0 removes all contrast (flat grey), 1 is the original. |
saturate | number | 0 – 2+ | 0 is fully desaturated (greyscale), 1 is the original saturation. |
hueRotate | number | degrees | Rotates all hues by the given number of degrees (e.g. 180 inverts hues). |
invert | number | 0 – 1 | 0 is the original colours, 1 fully inverts them. |
opacity | number | 0 – 1 | 0 is fully transparent, 1 is fully opaque. |
Applying multiple filters
Any combination of props can be set on the same sprite:Reactive filters
Every filter prop accepts aSignalGetter<number> (or SignalGetter<Color> for modulate) in place of a plain value. The sprite re-renders automatically whenever the signal changes — no extra effect or manual update needed.
brightness, not brightness()) directly as the prop value. tiny-engine tracks the dependency and schedules a re-draw on change.
The Color type
Color is a fixed-length RGBA tuple where every channel is a number in the 0–1 range:
tiny-engine:
rgba() but normalised to 0–1 rather than 0–255. An alpha of 1 is fully opaque; 0 is fully transparent.
Color is also used by Rectangle.fillColor and Rectangle.strokeColor.
Modulate tinting
Themodulate filter differs from the other numeric filters. Instead of using ctx.filter, it:
- Draws the sprite normally.
- Sets
ctx.globalCompositeOperation = 'multiply'. - Fills the sprite bounds with a rectangle of the given RGBA colour.
modulate of [1, 1, 1, 1] (white) leaves the sprite unchanged, while [1, 0, 0, 1] (red) keeps only the red channel, tinting the sprite red.
Numeric filters (
brightness, grayscale, contrast, saturate, hueRotate, invert, opacity) are combined into a single ctx.filter string and applied together before drawing. When multiple filters are set, they stack — for example, setting both brightness={0.5} and contrast={2} applies both adjustments in a single pass. modulate is applied as a separate compositing step after the main draw.