Fraxel’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/fraxel/llms.txt
Use this file to discover all available pages before exploring further.
<sprite> node exposes eight visual filter props that map directly onto the browser’s Canvas 2D rendering pipeline. Most filters write to ctx.filter as a CSS-filter string (e.g. brightness(1.2) grayscale(0.5)) before each draw call; the modulate tint uses globalCompositeOperation: 'multiply' instead, blending a filled rectangle over the sprite in a separate pass. Because every filter prop accepts a reactive value — a plain number, a signal getter, or a computed function — filters update automatically frame-by-frame whenever their source signal changes, with no manual invalidation required.
Available Filters
All eight filters can be combined on a single<sprite>:
Filter Reference
| Prop | Type | Default | Range / Effect |
|---|---|---|---|
brightness | number | 1 | 0 = fully black · 1 = original · 2 = fully white |
grayscale | number | 0 | 0 = full color · 1 = fully grayscale |
modulate | Color | [1,1,1,1] | RGBA multiply tint; each channel 0–1 (see below) |
contrast | number | 1 | 0 = no contrast · 1 = original · 2 = double contrast |
saturate | number | 1 | 0 = fully desaturated · 1 = original · 2 = double saturation |
hueRotate | number | 0 | Degrees of hue rotation, e.g. 180 for complementary colors |
invert | number | 0 | 0 = normal colors · 1 = fully inverted |
opacity | number | 1 | 0 = fully transparent · 1 = fully opaque |
Reactive Filters
Every filter prop accepts theReactive<T> type — which means it can be a plain static value, a signal getter () => value, or any zero-argument function returning the current value. When a getter is passed, Fraxel’s fine-grained reactivity system subscribes to it and re-evaluates it each frame the signal changes, updating the sprite with zero wasted work.
Example: grayscale tied to a health signal
Example: brightness on hover
brightness receives a getter function () => hovered() ? 1.4 : 1, Fraxel automatically tracks the hovered signal and re-applies the filter only when it changes — no polling, no manual updates.
The Color Type
Color is a plain TypeScript tuple [number, number, number, number] representing an RGBA color with each channel in the 0–1 range. It is used by Sprite.modulate and by Rectangle’s fillColor and strokeColor props.
[3]) in modulate controls the strength of the multiply blend — 1 applies the full tint, 0 leaves the sprite unaffected. This is distinct from opacity, which controls the overall transparency of the entire sprite.
modulate vs opacity
These two props both affect how transparent or tinted a sprite appears, but they work differently:
modulate | opacity | |
|---|---|---|
| Mechanism | Canvas globalCompositeOperation: 'multiply' fill pass | ctx.filter = 'opacity(n)' applied per pixel |
| Effect | Multiplies each pixel’s RGB channels by the tint color — dark colors darken the sprite, bright colors shift its hue | Uniformly scales the alpha of every pixel |
| Use for | Color tints, damage flash, elemental effects | Fade in/out, ghost effects, UI overlays |
| Default | [1, 1, 1, 1] (no change) | 1 (fully opaque) |
modulate example — a red damage flash:
opacity example — fade out when dying:
Related pages: Nodes 2D · Reactivity · Hooks · Animation · Assets · API: Nodes 2D