Media
The img element with a still, a sprite sheet or a video; wrapping media in a phone, a window, a camera or a 3D card; and what media work is not supported yet.
All media goes through one element, img. It draws a still picture, one cell of a sprite sheet, or a video played in step with scene time. Everything else on this page is a component or a box wrapped around an img.
The img element#
| Prop | Type | Meaning |
|---|---|---|
src | string | A URL, a data URI, or a path the host maps to a URL. With no src the element draws a labelled placeholder. |
w, h | pixels | The box. Default 600 by 400. |
fit | cover, contain | How the picture fills the box. Default cover. |
radius | 0 to 999 | Corner radius. Default 28. Set 0 for full-frame footage. |
shadow | 0 to 3 | A drop shadow. |
label, fill | string, colour | The placeholder's words and colour. |
sheet | { columns, rows } | Treats src as a sprite sheet of equal cells in row order. |
frame | number, may be live | The zero-based cell to show. Holds the last cell when it runs past the end. |
clip | string | The same picture as a video file, played over the still or the sheet. |
Paths are resolved by the host. The fourth argument of mount maps the paths a scene uses to URLs: mount(host, compiled, fonts, { "assets/interview.webp": "/media/interview.webp" }). A path with no entry is used as written. Scenes therefore carry short stable names and never a host's URL.
A still#
{ "el": "img", "src": "assets/editor.webp", "w": 960, "h": 540, "radius": 22, "shadow": 2 }Leave src out while the file does not exist. The placeholder has the same size, so the layout and the motion can be designed first.
A sprite sheet#
A sprite sheet is one image holding the frames of a short take in a grid. sheet gives the grid. frame picks the cell. Because frame can be an expression, the take is seeked by scene time and can be scrubbed to any second in any order.
"frame": "=t*12"plays a 12 frames per second sheet from the start of the scene."=lt*12"plays it from the node's own start."frame": "=mod(t,6)*12"loops a six second sheet.- Match the box to one cell's aspect ratio. The sheet is stretched so that one cell fills the box.
A video#
clip names a video file of the same picture. The renderer lays a muted video over the still or the sheet once the browser can play it. While scene time moves forward at about real speed the video plays on its own and is nudged when it drifts. A scrub or a pause sets its frame directly. If the video fails to load, the still or the sheet underneath stays.
{ "el": "img", "src": "assets/interview.webp", "clip": "assets/interview.mp4",
"w": 1080, "h": 1920, "radius": 0,
"sheet": { "columns": 9, "rows": 8 }, "frame": "=t*12" }clip needs src: the still or sheet is the fallback and the first paint. The video always starts at scene second 0 and plays at normal speed.
Wrapping media in components#
These components take children, so any of them can hold an img or another component.
| Component | What it adds | Props |
|---|---|---|
| Phone | A phone body. Content is clipped to the screen. | w, h, fill |
| Window | An app window with a title bar. | title, w, fill, pad, gap |
| Float3D | A slow 3D tilt and a gentle float. | tilt, float, period, perspective |
| PushIn | A camera: pushes in on a point, then pulls back. | zoom, focus, at, back, curve |
| LayerPlate | Three ordered layers in one clipped frame: back, subject, overlay. | fill, three slots |
| IrisWindow | A circular aperture that opens over its media slot. | diameter, curve, tint |
A camera move on a screenshot is one wrapper. focus is [x, y] as fractions, or "#id" of a node inside:
{
"size": [1280, 720],
"duration": 6,
"background": "ground",
"root": {
"el": "PushIn", "zoom": 2.2, "focus": "#shot", "at": 1.5, "back": 4.5,
"children": [
{ "el": "Window", "title": "Dashboard", "w": 760, "children": [
{ "el": "img", "id": "shot", "label": "screenshot", "w": 680, "h": 360, "radius": 12 }
] }
]
}
}For text behind a speaker, LayerPlate takes the footage and the title in back, a transparent cut-out of the speaker in subject, and captions in overlay. The cut-out is a second sheet or video with an alpha channel that you supply. The kit does not make one.
Depth#
3D is opt-in per box.
| Prop or channel | On | Meaning |
|---|---|---|
perspective | a box | 100 to 5000. Gives the box's children depth. Smaller is a stronger effect. |
space | a box | true lets its children keep their own depth while the box itself turns. Use it on a box that rotates in 3D with children at different z. |
z | a pose | Pixels towards the camera. |
rotateX, rotateY | a pose | Degrees around the horizontal and vertical axes. |
backface | any node | false hides the node while it faces away. Give it to both faces of a card that flips. |
The pose channels are set by behaviors: enter from "flip", "swing", "fly" or "fly-past", a loop of kind "tilt", or drive for anything else. A depth move under no perspective looks flat, and the check reports it as a note.
A custom 3D card#
A wrapper of your own is a component with "$children". This one sets a perspective, clips its content to rounded corners, swings in and then turns slowly. Its img has no src, so it shows the placeholder.
turn and period are props, so an instance can write { "el": "Card3D", "turn": 40 }.Masks#
Three kinds of mask exist. All three can follow a signal.
| Mask | Written as | On |
|---|---|---|
| Circle | "aperture": "=0.25+0.75*open" (0 closed, 1 open) | any node |
| Spotlight | spotX, spotY (0 to 1 across the box), spotR (pixels) | a box |
| Wipe | The pose channels clipT, clipR, clipB, clipL (percent hidden from that side), or the poses wipe-up, wipe-down, wipe-left, wipe-right | any node |
A box with "clip": true also hides whatever goes outside it, with its corner radius. That is how the Phone screen and the 3D card above crop their content.
Not supported yet#
- No export to a video file. A scene plays in the browser.
- No slicing of a video or an image into tiles that move apart.
- No playback speed, reverse or trim for a
clip. A sprite sheet can be retimed throughframe, a video cannot. - No masks beyond the circle, the spotlight and the wipes. No arbitrary path masks. No blend modes.
- No sound. A
clipis always muted, and the scene'saudiofield is for a host to play. - No object carried across scenes: a picture cannot leave one scene of a Sequence and continue in the next as the same node.
- No knowledge of what a picture shows. Nothing in the kit detects where a face is in a frame.
Direction lists these in the order they are planned.