editor/docs/reference/jsx/elements.md
konstantin-paulus 2c736e5f4a Add PivotRow component and integrate pivot functionality into transform settings
- Introduced a new PivotRow component to manage pivot properties (pivotX, pivotY) for entities.
- Updated TransformSettings to conditionally display PivotRow instead of AnchorRow based on the entity's pivot state.
- Enhanced the clip-path and group handling logic to utilize pivot instead of anchor for transformations.
- Updated documentation to reflect the new pivot properties and their usage in the context of groups and transformations.
2026-10-10 13:02:21 +02:00

135 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Element reference
camelCase composition elements map 1:1 onto entities. Lowercase DOM vocabulary is valid only inside [`<html>`](./html.md) content.
## Structure
| Element | What it is |
| ------- | ---------- |
| [`<stage>`](./stage.md) | The infinite canvas, and the only valid root. Holds `<scene>` children, and loose nodes parked beside them. |
| [`<scene>`](./scene.md) | A clipped, playable frame; owns the timeline its children sit on. Only under `<stage>`, never nested. |
| [`<group>`](./group.md) | Container with a transform; auto-fits its box and its span from its children. No size and no fill of its own. |
| [`<sequence>`](./sequences.md) | Track-like container for back-to-back clips, and where [transitions](./transitions.md) are declared. No transform of its own. |
## Nodes
| Element | What it is |
| ------- | ---------- |
| [`<rect>`](./rect.md) | A rectangle. Takes paints, strokes, shadows and effects. With `clipPath` it clips its parent instead of drawing. |
| [`<ellipse>`](./ellipse.md) | An ellipse inscribed in its box. Takes what a rect takes. |
| [`<polygon>`](./polygon.md) | A regular polygon (`pointCount` corners, a triangle by default) stretched to fill its box. Takes what a rect takes. |
| [`<path>`](./path.md) | A vector outline from SVG path data (`d`), in its box's pixels or stretched from a `viewBox`; morphs between keyframes and trims. Takes what a rect takes. |
| [`<text>`](./text.md) | Text; its children are the glyphs. Sizes itself to them unless given a box. |
| [`<textRange>`](./text.md#textrange) | A style override over a run of the parent `<text>`'s glyphs, by character index. |
| [`<video>`](./video.md) | A video clip: a rect whose intrinsic paint is the media `src` names. |
| [`<image>`](./image.md) | A picture: a rect whose intrinsic paint is the media `src` names. |
| [`<audio>`](./audio.md) | A clip with a sound and no picture; on the canvas, a waveform box. |
| [`<captions>`](./captions.md) | A styled, timed transcript, mounted from a transcript file or an asset that carries one. |
| [`<adjustmentLayer>`](./adjustment-layer.md) | Draws nothing; its transform composes onto the clip directly below it, for as long as its own clip lasts. |
| [`<html>`](./html.md) | A rect whose paint is real, reactive HTML drawn into the box by the browser. |
| [`<surface>`](./surface-paint.md) | A rect whose paint is a canvas your `ref` draws into, sampled every frame. |
## Paints
Children of a node, stacked in document order over its intrinsic fill. See [paints.md](./paints.md).
| Element | What it is |
| ------- | ---------- |
| `<solidPaint>` | A solid color; what the `fill` prop is shorthand for. |
| `<linearGradientPaint>` / `<radialGradientPaint>` / `<angularGradientPaint>` | A gradient; takes `<colorStop>` children. |
| `<colorStop>` | One gradient stop. Valid only inside a gradient paint. |
| `<imagePaint>` / `<videoPaint>` | Media painted into another element's box — a rect or a text filled with a picture. |
| [`<htmlPaint>`](./html.md) | The paint form of `<html>`. |
| [`<surfacePaint>`](./surface-paint.md) | The paint form of `<surface>`. |
| [`<shaderPaint>`](./shader-paint.md) | A WGSL fragment shader over the media paint below it, or procedural where there is none. |
## Styles and motion
Sub-entity children of the node (or paint) that holds them. See [styles.md](./styles.md), [animations.md](./animations.md), [keyframes.md](./keyframes.md).
| Element | What it is |
| ------- | ---------- |
| `<stroke>` | An outline of the parent's box or glyphs, in its `color` or its solid and gradient paint children. Several stack. |
| `<shadow>` | A drop shadow beneath the parent's silhouette. Several stack. |
| `<effect>` | A CSS-style filter over the parent's rendered pixels. Several stack. |
| `<mask>` | A matte limiting the `<effect>` holding it: the alpha of a tracked frame sequence. Under an `opacity` effect, the cut-out. See [styles.md](./styles.md#mask). |
| `<animation>` | One preset in/out animation of the node holding it. |
| `<keyframeTrack>` | The keyframes of one prop of the element holding it. |
| `<keyframe>` | One keyframe of the track holding it. |
User-defined components are ordinary Solid components; they compose the elements above and carry no runtime cost. Only the elements above produce entities.
## Coordinates and sizing
- Coordinates are **pixels relative to the parent's box**, origin top-left. No percentages, no layout keywords; explicit numbers until the layout engine lands.
- `x` and `y` default to `0`. **Size defaults are per element**, not inherited from the parent:
| Element | Default box |
| ------- | ----------- |
| `<video>`, `<image>`, `<adjustmentLayer>` | 1920 × 1080 |
| `<scene>` | required — the frame's own size |
| `<rect>`, `<ellipse>`, `<polygon>`, `<path>`, `<html>`, `<surface>` | 100 × 100 |
| `<audio>` | 500 × 150 (the waveform box on the canvas) |
| `<rect clipPath>` | 500 × 500 |
| `<text>` | fits its glyphs |
| `<captions>` | the preset's — it lays out the caption block against the scene's frame |
| `<group>`, `<sequence>` | fits its children |
- A `<text>` given neither `width` nor `height` sizes itself to what it says; giving it either fixes the box and wraps into it.
- `<group>` and `<sequence>` never take a size: theirs is the union of their children's.
- How media pixels map into the box is controlled by `objectFit` (default `"cover"`), never by the box itself. A media element therefore always has a definite size, even before its asset has loaded.
## Common props
Every node accepts:
| Prop | Type | Default | Meaning |
| ---- | ---- | ------- | ------- |
| `id` | `string` | stamped | How the element is addressed — by the editor writing back to it, by `capture`, by [`syncTo`](./audio-sync.md). Written into your source if you leave it out (see [module.md](./module.md#ids)). |
| `ref` | `SceneNode` variable or `(node: SceneNode) => void` | none | SolidJS-style ref; receives the element's node when it is created. For `<surface>`/`<surfacePaint>` the node's `element` is the backing canvas (see [surface-paint.md](./surface-paint.md)). |
| `name` | `string` | none | Human-readable node name; what labels the node in the editor. |
| `x`, `y` | `number` | `0` | Position relative to the parent, px. |
| `offsetX`, `offsetY` | `number` | `0` | Render-time translation on top of `x`/`y`, px; moves the drawn content without changing the layout box (the channel the slide animations drive). Subpixel values are kept. |
| `width`, `height` | `number` | per element | Box size, px — see the table above. |
| `keepAspectRatio` | `boolean` | absent | Locks the box to its authored proportions: resizing one bound (an editor handle, a layout row) drives the other so the ratio `width`:`height` has is kept — or, with neither authored, the ratio the box currently has. |
| `constrainX` | `"left" \| "right" \| "center" \| "stretch" \| "scale"` | `"left"` | How the element follows its scene's frame when that frame is resized, horizontally — see below. |
| `constrainY` | `"top" \| "bottom" \| "center" \| "stretch" \| "scale"` | `"top"` | The same vertically. |
| `rotation` | `number` | `0` | Rotation in degrees, about the pivot. |
| `pivotX`, `pivotY` | `number` | box centre (`<group>`: `0`) | The point `rotation` and scale turn about, px in the element's own space — from its box's top-left, or for a [`<group>`](./group.md#pivot) in its children's coordinates — like SVG's `rotate(angle cx cy)`. An axis left out of a pivot that has the other is `0`. Not animatable. |
| `scale` | `number` | `1` | Uniform scale about the pivot. Overrides `scaleX`/`scaleY` while set. |
| `scaleX`, `scaleY` | `number` | `1` | Per-axis scale. |
| `opacity` | `number` | `1` | `0`–`1`; out-of-range values clamp, like CSS. |
| `cornerRadius` | `number` | `0` | Uniform corner radius, px. |
| `cornerRadiusTopLeft`, `cornerRadiusTopRight`, `cornerRadiusBottomRight`, `cornerRadiusBottomLeft` | `number` | `cornerRadius` | Per-corner radius, px; a corner without one takes `cornerRadius`, so `cornerRadius={20} cornerRadiusTopLeft={0}` rounds three corners. |
| `blendMode` | `BlendMode` | `"sourceOver"` | How the element composites over what is below it: the canvas blend modes, camelCase — `multiply`, `screen`, `overlay`, `darken`, `lighten`, `colorDodge`, `colorBurn`, `hardLight`, `softLight`, `difference`, `exclusion`, `hue`, `saturation`, `color`, `luminosity`. |
| `hidden` | `boolean` | absent | Excludes the element from rendering (and its audio from the mix) without removing it: it keeps its place in the timeline and its children. |
| `start`, `end`, `sourceIn`, `sourceOut` | `Time` | see [timing.md](./timing.md) | Temporal placement. |
| `playbackRate` | `number` | `1` | Speed multiplier for the node's local time (see [timing.md](./timing.md#playback-rate)). |
| `transition` | `TransitionSpec \| null` | none | Transition into the next clip; direct children of `<sequence>` only (see [transitions.md](./transitions.md)). |
Props are animated by [`<keyframeTrack>`](./keyframes.md) children naming them; preset in/out effects are [`<animation>`](./animations.md) children. No prop takes keyframes inline.
### Constraints
`constrainX` and `constrainY` say what an element does when **the frame it sits in is resized** — a scene taken from 1920×1080 to 1080×1920, say. Nothing else reads them: a constraint moves nothing at the moment it is written, only the next time the frame changes size.
| Value | `constrainX` | `constrainY` |
| ----- | ------------ | ------------ |
| `"left"` / `"top"` | Keeps its distance from the left edge — where an element with no constraint stays. | The same from the top edge. |
| `"right"` / `"bottom"` | Keeps its distance from the right edge, so it travels with it. | The same from the bottom edge. |
| `"center"` | Keeps its position relative to the middle of the frame. | The same vertically. |
| `"stretch"` | Holds both margins, so the element is **resized** by the frame's width delta. | Holds the top and bottom margins, resizing its height. |
| `"scale"` | Position and width take the frame's horizontal ratio, so the element keeps its share of the frame. | The same vertically. |
### Editor state
Three more props are written by the editor and read back on the next mount. They are not part of the composition — nothing rendered or exported depends on them — but the source is the document, so a row resized in the timeline has nowhere else to be remembered:
| Prop | Type | Meaning |
| ---- | ---- | ------- |
| `selected` | `boolean` | Whether the editor has the element selected. Absent means not. |
| `clipHeight` | `number` | Height of the element's row in the timeline, px. Absent means the common row height. |
| `expanded` | `boolean` | Whether the timeline shows the element's keyframe rows below its clip. Absent means collapsed. |
Write them or delete them freely; the editor rewrites its own.