Background Animations
background_animation draws moving layers behind a card's content: grids, starfields, nebulae, an LCARS data cascade, a warp field, a rotating planet. It works on the button, elbow, slider, MSD and astrometrics cards.
- The value is a list of effects. Each entry names a
presetand gives that preset's keys inconfig; the first entry is the bottom layer. - The background sits behind the card's own fill, so it shows best on a card with a transparent fill, such as the button's
outlinepreset, or inside an elbow's arms. - On the MSD card it goes under
msd:(msd.background_animation); on every other card it is a top-level key.
Try it
- The button and elbow editors have a Background Animation section on the Effects tab, with every preset's keys and a live preview. The MSD and Astrometrics Studios have one too.
| Page | Covers |
|---|---|
| Preset Reference | Every preset and its config keys |
| Stacking and Zoom | Layering several effects, the zoom wrapper, example backgrounds |
| Binding and Animation | Keys that follow an entity, animating the background from triggers and rules, the animatable keys |
Quick start
Two backgrounds to start from: a scrolling grid behind a button, and a data cascade inside an elbow's arms.
- Give the card some height (
grid_options.rowsin a sections view) so there is room to see the effect. - On an elbow,
inset: autokeeps the background inside the bars; see Canvas options.
type: custom:lcards-button
preset: outline
text:
name:
content: SENSOR GRID
show: true
grid_options:
rows: 3
background_animation:
- preset: grid
config:
line_spacing: 30
color: alpha(var(--lcars-orange), 0.4)
scroll_speed_x: 15
scroll_speed_y: 15type: custom:lcards-elbow
grid_options:
rows: 4
elbow:
type: header-left
segment:
bar_width: 90
bar_height: 20
color: var(--lcars-orange)
background_animation:
inset: auto # inside the bars
effects:
- preset: cascadeAvailable presets
preset picks the effect; the Preset Reference lists each one's config keys. There are seventeen.
configis optional for most presets: a key you leave out takes the preset's default.imageneeds asource.- The presets marked WebGL draw on the GPU where the browser has WebGL and fall back to a Canvas2D version where it does not; see WebGL presets.
| Preset | Draws |
|---|---|
grid | A grid with optional major and minor lines; polar rings and spokes (pattern: polar); on WebGL also a perspective floor (view: floor) or a cylinder, dome, sphere or funnel (surface) |
grid-diagonal | Diagonal hatching (WebGL) |
grid-hexagonal | A honeycomb (WebGL) |
starfield | Scrolling stars in parallax depth layers |
nebula | Soft nebula clouds; volumetric: true shades them with noise on WebGL |
contour-field | Banded contours like a star chart (WebGL) |
cascade | The LCARS data waterfall: rows of numbers cycling colour |
level | A fill bar with waves and sloshing, for a tank or gauge |
fluid | A swirling colour wash (WebGL) |
plasma | Two-colour plasma bands (WebGL) |
flow | Streaks streaming in one direction |
shimmer | A highlight band sweeping across |
scanlines | CRT-style scanlines |
image | An image, fixed or from an entity |
solid | A flat colour |
warp-starfield | Stars flying at you in 3D, streaking at speed (WebGL; starfield without it) |
holo-sphere | A rotating wireframe planet with a scan band (WebGL; the same look on Canvas2D) |
WebGL presets
Some presets draw on the GPU with three.js where the browser has WebGL, and fall back to Canvas2D where it does not, so the background never goes blank. renderer on the entry chooses.
warp-starfieldandholo-sphereare three.js scenes. Without WebGL,warp-starfielddraws astarfieldandholo-spherethe same sphere on Canvas2D.grid,grid-diagonalandgrid-hexagonaldraw the same pixels as their Canvas2D versions in the flat view. On WebGL they also do a perspective floor with a camera (grid views), cylinders, domes and spheres seen from outside or inside (grid surfaces), and funnels that can morph and ripple (grid wells).contour-field,plasmaandfluiddraw the same field on the GPU, with the same keys. On WebGL their noise keys become animatable.nebulauses WebGL only withvolumetric: true(opt-in, because it changes the look); without WebGL it draws the plain clouds.
grid, view: floorYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: grid
config:
view: floor
color: var(--lcards-orange)
line_width: 2
grid_options:
rows: 4
grid-hexagonal, view: floorYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: grid-hexagonal
config:
view: floor
line_width_minor: 2
grid_options:
rows: 4
grid, majors, tiltedYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: grid
config:
view: floor
camera_tilt: 40
camera_yaw: 20
color: var(--lcards-orange)
major_row_interval: 4
major_col_interval: 4
color_major: var(--lcards-moonlight)
line_width_major: 3
grid_options:
rows: 4
holo-sphereYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: holo-sphere
config:
line_width: 1.5
grid_options:
rows: 4
warp-starfieldYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: warp-starfield
config:
count: 800
speed: 3
grid_options:
rows: 4
nebula, volumetricYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: nebula
config:
cloud_count: 5
colors: [var(--lcards-purple), var(--lcards-blue-medium), var(--lcards-orange)]
volumetric: true
grid_options:
rows: 4
contour-fieldYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: contour-field
config:
num_bands: 7
colors: [var(--lcards-blue-darkest), var(--lcards-blue-medium), var(--lcards-blue-light)]
grid_options:
rows: 4
plasmaYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: plasma
grid_options:
rows: 4
fluidYAML
type: custom:lcards-elbow
elbow:
type: frame
segment:
color: var(--lcards-gray)
frame:
bar_width: 4
bar_height: 4
outer_curve: 10
background_animation:
inset: auto
effects:
- preset: fluid
config:
color: var(--lcards-blue-light)
grid_options:
rows: 4
Real cards with sample entities. Drawn with WebGL in your browser; without it each falls back to its Canvas2D version.
type: custom:lcards-button
preset: outline
text:
name:
content: WARP
show: true
grid_options:
rows: 3
background_animation:
- preset: warp-starfield
config:
count: 400type: custom:lcards-button
preset: outline
text:
name:
content: CANVAS2D
show: true
grid_options:
rows: 3
background_animation:
# always the Canvas2D version: for warp-starfield, a starfield
- preset: warp-starfield
renderer: canvas
config:
count: 400More about WebGL presets
- One context: a WebGL preset loads only when a card uses it, and all of them share one WebGL context across the dashboard. Each sits in the stack like any other entry.
- Why the GPU helps the noise presets: on the CPU,
contour-field,plasmaandfluidwork out their whole field when they first draw, resize or change alert colours, which can pause the page for a moment on a large background. On the GPU they don't. - A lost context: if the graphics context is lost (a GPU reset, a tablet app hiding the dashboard), the entry draws its Canvas2D version and goes back to the three.js scene within a few seconds, once the graphics work again. If a scene fails to start, or the context is lost three times within two minutes, that entry keeps its Canvas2D version until the page is reloaded.
- Off-screen: a three.js scene gives the shared context back while its card is off the page.
| Key | Type | Default | Description |
|---|---|---|---|
renderer | string | auto | auto: WebGL when the browser has it, Canvas2D otherwise. webgl: the same, stated outright. canvas: always the Canvas2D version (no GPU use). Presets that are Canvas2D only ignore it |
Effect options
The keys of one entry in the list: which preset, its settings, and how it is drawn. Any number of entries can be stacked; see Stacking and Zoom.
- Colours in
configtake every LCARdS colour form: CSS variables,theme:tokens,alpha()and the other computed colours, rgba and hex. See Colours. - Any
configvalue can follow an entity withmap_rangeor a template; see Binding and Animation.
type: custom:lcards-button
preset: outline
text:
name:
content: DEFLECTOR
show: true
grid_options:
rows: 3
background_animation:
- preset: starfield
config:
count: 150
speed: 0.5 # half speed
# kept in the list, drawn only once enabled
- preset: grid
enabled: false
config:
color: alpha(var(--lcars-orange), 0.3)More about effect options
speedand the zoom wrapper:speedalso runs the zoom cycle faster, whether it is fixed inconfig, bound to an entity or animated.- Disabled entries keep their place: an entry with
enabled: falsestill counts when an animation picks an entry by number (effect:).
| Key | Type | Default | Description |
|---|---|---|---|
preset | string | required | The effect: see Available presets |
config | object | the preset's defaults | The preset's own keys: see the Preset Reference |
config.speed | number | 1 | Time multiplier for every preset that moves (all but image and solid): 2 is twice as fast, 0 freezes it. On shimmer it is the sweep speed in px per second (default 6) |
enabled | boolean | true | false keeps the entry in the list but draws nothing |
renderer | string | auto | For presets with a WebGL version: see WebGL presets |
transition | number | 500 | Milliseconds an entity-bound value takes to glide to a new value. 0 snaps |
zoom | object | - | Draws the effect as layers zooming outward: see Zoom wrapper |
Canvas options
To set where the background is drawn, or its frame rate, write background_animation as an object with the list under effects. inset keeps the canvas off the card's edges, for a sidebar or footer bar that should stay clear.
inset: autoworks on elbow cards: it fits the canvas inside the elbow's arms and follows the bars when they change. The elbow's appearance page covers how it treats each elbow type. On every other cardautomeans no inset.- A side you leave out of an
insetobject is0. fpscaps how often the background redraws. It is read only in the object form.
type: custom:lcards-button
preset: outline
text:
name:
content: CANVAS INSET
show: true
grid_options:
rows: 3
background_animation:
inset:
left: 60 # keep the left 60 px clear
bottom: 20
effects:
- preset: grid-hexagonal
config:
hex_radius: 20
color: alpha(var(--lcars-ice), 0.4)More about canvas options
- Frame rate: the default cap of 30 frames per second is plenty for ambient motion and spares low-end devices such as wall tablets. Set
60for a smoother look on a desktop or high-refresh screen;0removes the cap. The editor's Canvas Settings section sets it. - Size: the canvas follows the card's size as it changes (a sections grid settling, the sidebar opening), less the inset, and is never smaller than 1 px.
| Key | Type | Default | Description |
|---|---|---|---|
background_animation | list / object | - | A list of effects, or an object with effects, inset and fps |
effects | list | required in the object form | The effects, bottom layer first: see Effect options |
inset | string / object | none | auto: inside an elbow's arms (no inset on other cards). An object: px per side |
inset.top | number | 0 | Space kept clear at the top, px |
inset.right | number | 0 | Space kept clear on the right, px |
inset.bottom | number | 0 | Space kept clear at the bottom, px |
inset.left | number | 0 | Space kept clear on the left, px |
fps | number | 30 | Most frames per second the background draws. 0: no cap |
Troubleshooting
When a background doesn't show, looks wrong or slows a device down, check these first.
- Nothing shows: the card's own fill may cover it (try the button's
outlinepreset), the colour may be fully transparent, or the card may have no height to draw in. A preset name the card doesn't know is logged in the browser console and that entry is skipped. - A colour doesn't resolve: check that a
theme:token path exists in the active theme (Themes). Quote hex colours ("#ff9966"): unquoted, YAML reads everything after#as a comment. - A device slows down: use fewer stacked effects and fewer zoom layers, wider
line_spacing, and set scroll speeds to0where you don't need the motion.
More about how a background runs
- Pauses on its own: the background stops drawing while its card is scrolled off the page or the browser tab is hidden, and carries on where it left off.
- Reduced motion: when the device asks for reduced motion, the background draws one frame and holds it.
- A struggling device: if the frame rate falls very low, the background pauses itself and tries again later.
- Patterns that line up: stacked grids line up best with the same
line_spacing(or multiples of it), and major line intervals that divide the card's size evenly. - A different system: Animations animate a card's own parts; background animations are drawn on a canvas behind them. An animation can still target the background. Filters are SVG filter effects on the card.