Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

TL7b: in progress: an effect as a clip: <Effect kind amount in out> filters the picture under it for its sequence's frames (blur, mono, sepia, vivid, faded, contrast, bright, dark, invert, hue), one table for the engine and the timeline's preview; the timeline reads a sequence holding one as an effect clip and writes one added

shinyobjectz0a7c064b05a4
diff --git a/docs/manual/reference/sdk/index.md b/docs/manual/reference/sdk/index.md
index d7fa046e..214a00d6 100644
--- a/docs/manual/reference/sdk/index.md
+++ b/docs/manual/reference/sdk/index.md
@@ -31,7 +31,7 @@ The composition, the app, and the specs and notes an agent writes.
| Import | What it's for | Exports |
| --- | --- | --- |
-| [`raea`](raea.md) | The main entry: compositions, sequences, time, interpolation, springs, footage, sound and words. | 19 components, 8 hooks, 58 functions, 9 values, 95 types |
+| [`raea`](raea.md) | The main entry: compositions, sequences, time, interpolation, springs, footage, sound and words. | 20 components, 8 hooks, 60 functions, 10 values, 97 types |
| [`raea/app`](app.md) | The App, its plugins and schedules, and the registry a video's compositions are kept in. | 1 component, 4 functions, 3 classes, 17 values, 8 types |
| [`raea/brief`](brief.md) | The specs an agent writes as data: brief, script, taste, plan and controller, checked against raea's schemas. | 6 functions, 32 types |
| [`raea/note`](note.md) | A person's note as a file in the project: their words kept as written, and the asks the agent restates it as. | 1 function, 4 types |
diff --git a/docs/manual/reference/sdk/raea.md b/docs/manual/reference/sdk/raea.md
index d5c1d3e2..b12fd2a2 100644
--- a/docs/manual/reference/sdk/raea.md
+++ b/docs/manual/reference/sdk/raea.md
@@ -38,7 +38,7 @@ See [Your first video](../../start/first-video.md) for the whole loop, and
import { AbsoluteFill, ACTION_KEY, actionsIn, Animate } from "raea"
```
-`raea` exports 19 components, 8 hooks, 58 functions, 9 values, 95 types. Source: [sdk/raea/src/index.tsx](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/index.tsx).
+`raea` exports 20 components, 8 hooks, 60 functions, 10 values, 97 types. Source: [sdk/raea/src/index.tsx](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/index.tsx).
## Components
@@ -110,6 +110,17 @@ Declares a composition inside the root. It draws nothing itself; a renderer find
Used in: [ui/images/image_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node.tsx), [ui/images/ui_texture_slice_flip_and_tile](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice_flip_and_tile.tsx), [ui/images/image_node_resizing](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/image_node_resizing.tsx), [ui/images/ui_texture_atlas_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas_slice.tsx), [ui/images/ui_texture_slice](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_slice.tsx), [ui/images/ui_texture_atlas](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/images/ui_texture_atlas.tsx), [ui/layout/grid](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx), [ui/layout/ghost_nodes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/layout/ghost_nodes.tsx), and 152 more.
+### `Effect`
+
+The picture under it, through the effect, for as long as its <Sequence> runs.
+
+| Prop | Type | What it does |
+| --- | --- | --- |
+| `kind` (required) | `string` | which effect: blur, mono, sepia, vivid, faded, contrast, bright, dark, invert or hue |
+| `amount` | `number` | how much of it, from 0 (none) to 1 (all, the default) |
+| `in` | `number` | frames it takes to come on at its part's start (0: on at once) |
+| `out` | `number` | frames it takes to go off by its part's end (0: off at once) |
+
### `Freeze`
Shows its children as they are at `frame`, whatever the parent's frame.
@@ -408,6 +419,22 @@ Hold the frame until `continueRender(handle)`. `label` names it if it's still op
function delayRender(label?: string, options?: { timeoutInMilliseconds?: number; } | undefined): number
```
+### `effectAt`
+
+How much of the effect is on at `frame` of a part `duration` frames long, coming on over `enter` and off over `exit`.
+
+```ts
+function effectAt(frame: number, duration: number, enter?: number, exit?: number): number
+```
+
+### `effectFilter`
+
+The CSS filter of `kind` at `amount` (0 to 1, clamped); undefined for a kind raea doesn't draw.
+
+```ts
+function effectFilter(kind: string, amount?: number): string | undefined
+```
+
### `fade`
opacity 0 to 1 over `frames` (6).
@@ -864,6 +891,8 @@ turn one round. Pass one as `interpolate`'s `easing`.
Used in: [manual: turntable](https://github.com/shinyobjectz/raea/blob/main/docs/manual/examples/turntable.tsx).
+### `EFFECTS`
+
### `FEED_KEY`
The prefix of the keys the app hands every panel for what it knows: `feed:transcript` (the conversation's last lines,
@@ -1109,6 +1138,18 @@ a split, a cut word or a moved span is a change to this list; the length becomes
| --- | --- | --- |
| `segments` | `readonly (readonly [number, number])[]` | the composition's own frame ranges, [from, to), played one after another |
+### `EffectKind`
+
+| Field | Type | What it is |
+| --- | --- | --- |
+| `kind` (required) | `string` | its name in the composition's code: <Effect kind> |
+| `title` (required) | `string` | what the person sees |
+| `filter` (required) | `(amount: number) => string` | the CSS filter at `amount` |
+
+### `EffectProps`
+
+The props of [`Effect`](#effect), tabled there.
+
### `ExtrapolateMode`
```ts
diff --git a/sdk/guides/craft/motion/footage.md b/sdk/guides/craft/motion/footage.md
index 226a9e96..868a8764 100644
--- a/sdk/guides/craft/motion/footage.md
+++ b/sdk/guides/craft/motion/footage.md
@@ -31,6 +31,11 @@
line between points: `speedCurve={[[0, 1], [0.5, 4], [1, 1]]}` speeds up to 4x at the middle and back. The sound
follows it. The clip then takes `speedLength(speedPoints("clip", curve), endAt - startFrom)` frames, so give its
`<Sequence>` that `durationInFrames` (rounded).
+- For a look over a stretch of time, put an `<Effect kind="mono" />` in a `<Sequence>` of its own, written after
+ the parts it covers: it filters everything drawn before it for that sequence's frames, and draws nothing itself.
+ Kinds: `blur`, `mono` (black and white), `sepia`, `vivid`, `faded`, `contrast`, `bright`, `dark`, `invert`, `hue`.
+ `amount` (0 to 1) says how much; `in` and `out` are the frames it takes to come on and go off. The feed's timeline
+ shows such a sequence as an effect clip, so the person can move, trim or retune it there.
- Use `<Img src>` for stills. The frame waits until the image has loaded. An image whose file isn't there fails the
render with "missing image: PATH"; a plain App prints that line and draws nothing.
diff --git a/sdk/raea/conformance/effect.test.tsx b/sdk/raea/conformance/effect.test.tsx
new file mode 100644
index 00000000..accf225e
--- /dev/null
+++ b/sdk/raea/conformance/effect.test.tsx
@@ -0,0 +1,33 @@
+// <Effect>: a look on the picture under it for its part's frames (docs/timeline.feature TL7b).
+import { expect, test } from "bun:test";
+import { AbsoluteFill, Effect, EFFECTS, effectAt, effectFilter, Sequence } from "../src";
+import { renderFrame } from "../src/test";
+
+const base = { frame: 0, fps: 30, width: 1080, height: 1920, durationInFrames: 90 };
+const at = (frame: number, el: JSX.Element) => renderFrame(<AbsoluteFill><div>under</div><Sequence from={30} durationInFrames={30}>{el}</Sequence></AbsoluteFill>, { ...base, frame });
+
+test("an effect is on for its sequence's frames, as a filter on what is behind it", () => {
+ expect(at(10, <Effect kind="mono" />)).not.toContain("data-effect");
+ const on = at(40, <Effect kind="mono" />);
+ expect(on).toContain('data-effect="mono"');
+ expect(on).toContain("backdrop-filter:grayscale(1)");
+ expect(at(70, <Effect kind="mono" />)).not.toContain("data-effect");
+});
+
+test("its amount scales it, and it comes on and goes off over the frames it is given", () => {
+ expect(at(40, <Effect kind="blur" amount={0.5} />)).toContain("backdrop-filter:blur(12px)");
+ // 10 frames in: a tenth on its first frame, all of it from its tenth; 10 frames out: a tenth on its last
+ expect(at(30, <Effect kind="mono" in={10} />)).toContain("backdrop-filter:grayscale(0.1)");
+ expect(at(39, <Effect kind="mono" in={10} />)).toContain("backdrop-filter:grayscale(1)");
+ expect(at(59, <Effect kind="mono" out={10} />)).toContain("backdrop-filter:grayscale(0.1)");
+ expect(effectAt(0, 30, 10, 10)).toBeCloseTo(0.1, 6);
+ expect(effectAt(15, 30, 10, 10)).toBe(1);
+});
+
+test("every kind gives a filter, none at amount 0 changes the picture's numbers, and an unknown kind fails", () => {
+ for (const e of EFFECTS) expect(effectFilter(e.kind, 1)).toMatch(/^[a-z-]+\(/);
+ expect(effectFilter("vivid", 0)).toBe("saturate(1) contrast(1)");
+ expect(effectFilter("nope")).toBeUndefined();
+ expect(() => at(40, <Effect kind="nope" />)).toThrow(/kind is one of/);
+ expect(() => at(40, <Effect kind="blur" amount={2} />)).toThrow(/amount/);
+});
diff --git a/sdk/raea/src/index.tsx b/sdk/raea/src/index.tsx
index 94d05bea..4e4795ef 100644
--- a/sdk/raea/src/index.tsx
+++ b/sdk/raea/src/index.tsx
@@ -55,6 +55,8 @@ export {
type RegisteredComposition,
} from "@raea/video/registry";
+export { Effect, effectAt, type EffectProps } from "@raea/video/effect";
+export { EFFECTS, effectFilter, type EffectKind } from "@raea/video/effects";
export { Nudge, type NudgeProps } from "@raea/video/nudge";
export { speedLength, speedPoints, speedSource, type SpeedPoint } from "@raea/video/speed";
export { Transition, type TransitionProps, type TransitionEdge, type TransitionKind } from "@raea/video/transition";
diff --git a/sdk/timeline/src/read.ts b/sdk/timeline/src/read.ts
index 3b1d3259..d07a3db0 100644
--- a/sdk/timeline/src/read.ts
+++ b/sdk/timeline/src/read.ts
@@ -4,6 +4,7 @@
// every operation is a code edit of its own (edits.ts).
import { type Clip, type Ease, empty, end, find, type Frames, type Key, type Timeline, type Track } from "./model"
import { apply, type Op } from "./ops"
+import { EFFECTS } from "./registry"
/** A <Sequence> as the host lists it: its place among the file's elements, its span in the composition's frames,
* the lane it sits on (nested ones below their parent, overlapping ones apart), and why it can't be rewritten. */
@@ -24,6 +25,8 @@ export interface SeqRow {
shows?: number
/** the words it shows, when words are all it shows: a text clip, its words changed by renaming it (TL7c) */
text?: string
+ /** the effect it puts on the picture under it, when an <Effect> is all it holds: an effect clip (TL7b) */
+ effect?: { kind: string; amount: number }
/** how it comes in and goes out: its <Transition>'s in and out (TL7a) */
in?: { kind: string; frames: number }
out?: { kind: string; frames: number }
@@ -49,6 +52,10 @@ export type SeqEdit =
| { op: "words"; i: number; text: string }
/** words put on the picture from `at` for `frames`: a new sequence after the composition's last (TL7c) */
| { op: "text"; at: number; frames: number; text: string }
+ /** an effect put on the picture from `at` for `frames`: a new sequence holding an <Effect>, after the composition's last (TL7b) */
+ | { op: "effect"; at: number; frames: number; kind: string; amount: number }
+ /** an effect clip's kind or amount */
+ | { op: "fx"; i: number; kind?: string; amount?: number }
/** how it comes in ("in") or goes out ("out"): its <Transition>'s edge set, or taken off with 0 frames (TL7a) */
| { op: "edge"; i: number; side: "in" | "out"; kind: string; frames: number }
/** a <Video>'s or an <Audio>'s own level (TL8a) */
@@ -71,7 +78,7 @@ export function fromSequences(rows: SeqRow[], fps: number): Timeline {
const media = rows.filter((r) => r.media)
rows = rows.filter((r) => !r.media)
const lanes = [...new Set(rows.map((r) => r.lane))].sort((a, b) => a - b)
- const clipsOf = (lane: number): Clip[] => rows.filter((r) => r.lane === lane).sort((a, b) => a.from - b.from).map((r) => ({ id: seqId(r.i), kind: r.text === undefined ? "sequence" : "text", name: r.text ?? r.label ?? r.name, start: r.from, length: Math.max(1, r.to - r.from), ...(r.locked && { locked: r.locked }), ...(r.speed && r.speed !== 1 && { speed: r.speed }), ...(r.curve?.length && r.shows && { curve: r.curve.map(([at, speed]) => ({ at, speed })), shows: r.shows }), ...(r.keys && Object.keys(r.keys).length && { keys: Object.fromEntries(Object.entries(r.keys).map(([p, ks]) => [p, ks.map(([at, value, ease]): Key => ({ at, value, ...(ease !== undefined && { ease }) }))])) }) }))
+ const clipsOf = (lane: number): Clip[] => rows.filter((r) => r.lane === lane).sort((a, b) => a.from - b.from).map((r) => ({ id: seqId(r.i), kind: r.effect ? "effect" : r.text === undefined ? "sequence" : "text", name: r.effect ? (EFFECTS.find((e) => e.kind === r.effect!.kind)?.title ?? r.effect.kind) : (r.text ?? r.label ?? r.name), ...(r.effect && { props: { effect: r.effect.kind, amount: r.effect.amount } }), start: r.from, length: Math.max(1, r.to - r.from), ...(r.locked && { locked: r.locked }), ...(r.speed && r.speed !== 1 && { speed: r.speed }), ...(r.curve?.length && r.shows && { curve: r.curve.map(([at, speed]) => ({ at, speed })), shows: r.shows }), ...(r.keys && Object.keys(r.keys).length && { keys: Object.fromEntries(Object.entries(r.keys).map(([p, ks]) => [p, ks.map(([at, value, ease]): Key => ({ at, value, ...(ease !== undefined && { ease }) }))])) }) }))
const first = lanes.length ? clipsOf(lanes[0]) : []
const gapless = first.length > 0 && first.every((c, n) => c.start === (n ? end(first[n - 1]) : 0))
const tracks: Track[] = lanes.map((lane, n) => ({ id: n === 0 && gapless ? "main" : `overlay-${lane}`, kind: n === 0 && gapless ? "main" : "overlay", clips: clipsOf(lane) }))
@@ -182,6 +189,14 @@ export function seqEdits(t: Timeline, op: Op): SeqEdit[] | { why: string } {
case "set": {
// a speed or a speed curve is the footage's rate; anything else a sequence has is its own code's
const only = Object.keys(op.set).filter((k) => op.set[k as keyof typeof op.set] !== undefined)
+ // an effect clip's kind and amount are its <Effect>'s
+ if (only.length === 1 && only[0] === "props" && find(t, op.id)?.clip.kind === "effect") {
+ const { effect, amount, ...other } = op.set.props!
+ if (Object.keys(other).length) return { why: `an effect has a kind and an amount, not ${Object.keys(other).join(", ")}` }
+ if (effect !== undefined && !EFFECTS.some((e) => e.kind === effect)) return { why: `raea draws ${EFFECTS.map((e) => e.kind).join(", ")}: "${String(effect)}" isn't one of them` }
+ if (amount !== undefined && !(typeof amount === "number" && amount >= 0 && amount <= 1)) return { why: "an effect's amount runs from 0 to 1" }
+ return each([op.id], (r) => ({ op: "fx", i: r.i, ...(effect !== undefined && { kind: String(effect) }), ...(amount !== undefined && { amount: Math.round((amount as number) * 1000) / 1000 }) }))
+ }
// a text clip's name is its words
if (only.length === 1 && only[0] === "name") {
if (find(t, op.id)?.clip.kind !== "text") return { why: "a sequence's name is its own code's: only a text clip's words change here" }
@@ -215,8 +230,15 @@ export function seqEdits(t: Timeline, op: Op): SeqEdit[] | { why: string } {
return [{ op: "keys", i: r.i, keys: Object.fromEntries(Object.entries(keys).filter(([p]) => KEYED.includes(p)).map(([p, ks]) => [p, ks.map((k): [number, number, Ease?] => (k.ease === undefined || k.ease === "linear" ? [k.at, k.value as number] : [k.at, k.value as number, k.ease]))])) }]
}
case "add": {
+ // an effect put on the picture: a new sequence of its own, holding an <Effect>
+ if (op.clip.kind === "effect") {
+ const kind = String(op.clip.props?.effect ?? "")
+ if (!EFFECTS.some((e) => e.kind === kind)) return { why: `raea draws ${EFFECTS.map((e) => e.kind).join(", ")}: "${kind}" isn't one of them` }
+ const amount = typeof op.clip.props?.amount === "number" ? Math.min(1, Math.max(0, op.clip.props.amount)) : 1
+ return [{ op: "effect", at: Math.max(0, Math.round(op.clip.start)), frames: Math.max(1, Math.round(op.clip.length)), kind, amount }]
+ }
// words put on the picture: a new sequence of its own
- if (op.clip.kind !== "text") return { why: "only words are added to a composition here: footage and sound are its code's to place" }
+ if (op.clip.kind !== "text") return { why: "only words and effects are added to a composition here: footage and sound are its code's to place" }
return [{ op: "text", at: Math.max(0, Math.round(op.clip.start)), frames: Math.max(1, Math.round(op.clip.length)), text: (op.clip.name ?? "Text").trim() || "Text" }]
}
default:
diff --git a/sdk/timeline/src/registry.ts b/sdk/timeline/src/registry.ts
index 6cca0bf9..d493def0 100644
--- a/sdk/timeline/src/registry.ts
+++ b/sdk/timeline/src/registry.ts
@@ -4,6 +4,10 @@
import { EASES } from "./keys"
import { type Ease, type SpeedPoint, under } from "./model"
import { CURVES, FASTEST, SLOWEST } from "./speed"
+// raea's effects (TL7b): the one table the engine's <Effect> draws from, so a preview here is what a render shows
+import { EFFECTS, effectFilter, type EffectKind } from "../../video/src/effects"
+
+export { EFFECTS, effectFilter, type EffectKind }
export interface TransitionKind {
/** the component's name in the composition's code */
@@ -92,7 +96,7 @@ export function readAdds(raw: unknown): { adds: Adds; errors: string[] } {
}
/** Everything offered: raea's own, then each plugin's in order (a name a plugin before it took stays that one's). */
-export function palette(plugins: Adds[] = []): { eases: Record<string, Ease>; curves: Record<string, SpeedPoint[]>; transitions: TransitionKind[]; tracks: TrackKindInfo[] } {
+export function palette(plugins: Adds[] = []): { eases: Record<string, Ease>; curves: Record<string, SpeedPoint[]>; transitions: TransitionKind[]; tracks: TrackKindInfo[]; /** the effects a clip of its own puts on the picture (TL7b) */ effects: { kind: string; title: string }[] } {
const eases = { ...EASES }, curves = { ...CURVES }, transitions = [...TRANSITIONS], tracks = [...TRACKS]
for (const p of plugins) {
for (const [n, e] of Object.entries(p.eases ?? {})) if (!(n in eases)) eases[n] = e
@@ -104,5 +108,5 @@ export function palette(plugins: Adds[] = []): { eases: Record<string, Ease>; cu
if (t.under) under.add(t.kind)
}
}
- return { eases, curves, transitions, tracks }
+ return { eases, curves, transitions, tracks, effects: EFFECTS.map(({ kind, title }) => ({ kind, title })) }
}
diff --git a/sdk/timeline/test/read.test.ts b/sdk/timeline/test/read.test.ts
index 447af5a1..d88837cb 100644
--- a/sdk/timeline/test/read.test.ts
+++ b/sdk/timeline/test/read.test.ts
@@ -59,7 +59,20 @@ describe("TL0c: a timeline is read from a composition", () => {
expect(seqEdits(t, { op: "set", id: "seq-1", set: { name: " " } })).toEqual({ why: "a text clip says something: delete it to take its words off" })
expect(seqEdits(t, { op: "set", id: "seq-0", set: { name: "x" } })).toEqual({ why: "a sequence's name is its own code's: only a text clip's words change here" })
expect(seqEdits(t, { op: "add", kind: "text", clip: { id: "new", kind: "text", name: "Sale ends Friday", start: 45, length: 90 } })).toEqual([{ op: "text", at: 45, frames: 90, text: "Sale ends Friday" }])
- expect(seqEdits(t, { op: "add", kind: "video", clip: { id: "new", kind: "video", start: 0, length: 30 } })).toEqual({ why: "only words are added to a composition here: footage and sound are its code's to place" })
+ expect(seqEdits(t, { op: "add", kind: "video", clip: { id: "new", kind: "video", start: 0, length: 30 } })).toEqual({ why: "only words and effects are added to a composition here: footage and sound are its code's to place" })
+ })
+
+ test("a sequence holding an <Effect> is an effect clip: its kind and amount set, and one added is a new sequence (TL7b)", () => {
+ const t = fromSequences([{ ...rows[0] }, { ...rows[2], effect: { kind: "mono", amount: 0.5 } }], 30)
+ const fx = t.tracks.flatMap((k) => k.clips).find((c) => c.id === "seq-1")!
+ expect([fx.kind, fx.name, fx.props]).toEqual(["effect", "Black and white", { effect: "mono", amount: 0.5 }])
+ expect(seqEdits(t, { op: "set", id: "seq-1", set: { props: { amount: 0.8 } } })).toEqual([{ op: "fx", i: 1, amount: 0.8 }])
+ expect(seqEdits(t, { op: "set", id: "seq-1", set: { props: { effect: "sepia" } } })).toEqual([{ op: "fx", i: 1, kind: "sepia" }])
+ expect(seqEdits(t, { op: "set", id: "seq-1", set: { props: { amount: 3 } } })).toEqual({ why: "an effect's amount runs from 0 to 1" })
+ expect(seqEdits(t, { op: "add", kind: "effect", clip: { id: "new", kind: "effect", name: "Blur", props: { effect: "blur", amount: 0.4 }, start: 30, length: 60 } })).toEqual([{ op: "effect", at: 30, frames: 60, kind: "blur", amount: 0.4 }])
+ expect(seqEdits(t, { op: "add", kind: "effect", clip: { id: "new", kind: "effect", props: { effect: "sparkle" }, start: 30, length: 60 } })).toMatchObject({ why: expect.stringContaining('"sparkle" isn\'t one of them') })
+ // moved and trimmed like any sequence
+ expect(seqEdits(t, { op: "move", ids: ["seq-1"], by: 10 })).toEqual([{ op: "move", i: 1, from: 25, to: 70 }])
})
test("a <Video> and an <Audio> are clips of their own under their sequence: their level is theirs, the rest the sequence's", () => {
diff --git a/sdk/video/package.json b/sdk/video/package.json
index cc3cc48d..7281abbd 100644
--- a/sdk/video/package.json
+++ b/sdk/video/package.json
@@ -11,6 +11,8 @@
"./media": "./src/media.tsx",
"./timeline": "./src/timeline.tsx",
"./registry": "./src/registry.tsx",
+ "./effect": "./src/effect.tsx",
+ "./effects": "./src/effects.ts",
"./nudge": "./src/nudge.tsx",
"./speed": "./src/speed.ts",
"./transition": "./src/transition.tsx",
diff --git a/sdk/video/src/effect.tsx b/sdk/video/src/effect.tsx
new file mode 100644
index 00000000..1301b43e
--- /dev/null
+++ b/sdk/video/src/effect.tsx
@@ -0,0 +1,34 @@
+// Effect: a look put on everything drawn under it (docs/timeline.feature TL7b). The timeline writes an effect clip
+// as an <Effect> in a <Sequence> of its own after the parts it covers, so it is on for that sequence's frames and
+// moved, trimmed, split and deleted like any other clip. It draws nothing itself: it filters what is behind it.
+import { useLocalTime } from "@raea/app/clock";
+import { AbsoluteFill } from "./timeline";
+import { EFFECTS, effectFilter } from "./effects";
+
+export interface EffectProps {
+ /** which effect: blur, mono, sepia, vivid, faded, contrast, bright, dark, invert or hue */
+ kind: string;
+ /** how much of it, from 0 (none) to 1 (all, the default) */
+ amount?: number;
+ /** frames it takes to come on at its part's start (0: on at once) */
+ in?: number;
+ /** frames it takes to go off by its part's end (0: off at once) */
+ out?: number;
+}
+
+/** How much of the effect is on at `frame` of a part `duration` frames long, coming on over `enter` and off over `exit`. */
+export function effectAt(frame: number, duration: number, enter = 0, exit = 0): number {
+ const a = enter > 0 ? (frame + 1) / enter : 1;
+ const b = exit > 0 && Number.isFinite(duration) ? (duration - frame) / exit : 1;
+ return Math.min(1, Math.max(0, Math.min(a, b)));
+}
+
+/** The picture under it, through the effect, for as long as its <Sequence> runs. */
+export function Effect({ kind, amount = 1, in: enter = 0, out: exit = 0 }: EffectProps) {
+ const t = useLocalTime("Effect");
+ if (!EFFECTS.some((e) => e.kind === kind)) throw new RangeError(`Effect: kind is one of ${EFFECTS.map((e) => e.kind).join(", ")}, got ${String(kind)}`);
+ if (!Number.isFinite(amount) || amount < 0 || amount > 1) throw new RangeError(`Effect ${kind}: amount runs from 0 to 1, got ${amount}`);
+ for (const [name, v] of [["in", enter], ["out", exit]] as const) if (!Number.isFinite(v) || v < 0) throw new RangeError(`Effect ${kind}: ${name} must be 0 or more frames, got ${v}`);
+ const filter = effectFilter(kind, amount * effectAt(t.frame, t.duration, enter, exit));
+ return <AbsoluteFill data-effect={kind} style={{ backdropFilter: filter, pointerEvents: "none" }} />;
+}
diff --git a/sdk/video/src/effects.ts b/sdk/video/src/effects.ts
new file mode 100644
index 00000000..d1ac7e71
--- /dev/null
+++ b/sdk/video/src/effects.ts
@@ -0,0 +1,32 @@
+// The effects a clip of its own puts on the picture under it (docs/timeline.feature TL7b), as data: each a CSS
+// filter at an amount from 0 (none) to 1 (all of it). One table, so the engine's <Effect> and the timeline's
+// preview of an effect on a film draw the same thing.
+export interface EffectKind {
+ /** its name in the composition's code: <Effect kind> */
+ kind: string;
+ /** what the person sees */
+ title: string;
+ /** the CSS filter at `amount` */
+ filter: (amount: number) => string;
+}
+
+const n = (v: number) => String(Math.round(v * 1000) / 1000);
+
+export const EFFECTS: EffectKind[] = [
+ { kind: "blur", title: "Blur", filter: (a) => `blur(${n(a * 24)}px)` },
+ { kind: "mono", title: "Black and white", filter: (a) => `grayscale(${n(a)})` },
+ { kind: "sepia", title: "Sepia", filter: (a) => `sepia(${n(a)})` },
+ { kind: "vivid", title: "Vivid", filter: (a) => `saturate(${n(1 + a * 1.5)}) contrast(${n(1 + a * 0.15)})` },
+ { kind: "faded", title: "Faded", filter: (a) => `saturate(${n(1 - a * 0.6)}) contrast(${n(1 - a * 0.25)}) brightness(${n(1 + a * 0.08)})` },
+ { kind: "contrast", title: "Contrast", filter: (a) => `contrast(${n(1 + a)})` },
+ { kind: "bright", title: "Brighten", filter: (a) => `brightness(${n(1 + a * 0.6)})` },
+ { kind: "dark", title: "Darken", filter: (a) => `brightness(${n(1 - a * 0.6)})` },
+ { kind: "invert", title: "Invert", filter: (a) => `invert(${n(a)})` },
+ { kind: "hue", title: "Hue shift", filter: (a) => `hue-rotate(${n(a * 180)}deg)` },
+];
+
+/** The CSS filter of `kind` at `amount` (0 to 1, clamped); undefined for a kind raea doesn't draw. */
+export function effectFilter(kind: string, amount = 1): string | undefined {
+ const e = EFFECTS.find((x) => x.kind === kind);
+ return e?.filter(Math.min(1, Math.max(0, amount)));
+}
diff --git a/sdk/video/src/index.ts b/sdk/video/src/index.ts
index 5e8f9d69..a37ec20c 100644
--- a/sdk/video/src/index.ts
+++ b/sdk/video/src/index.ts
@@ -2,6 +2,8 @@
export * from "./media";
export * from "./timeline";
export * from "./registry";
+export * from "./effect";
+export * from "./effects";
export * from "./nudge";
export * from "./speed";
export * from "./transition";
diff --git a/tools/taxonomy.list b/tools/taxonomy.list
index 4759df41..5df465b6 100644
--- a/tools/taxonomy.list
+++ b/tools/taxonomy.list
@@ -18,6 +18,7 @@ raea Composition a composition declared in the root (id, size, fps, length),
raea Series shots one after another on the timeline
raea Freeze its children held at one frame
raea Nudge its child moved in front of its own transform
+raea Effect a look (blur, black and white, sepia and more) on everything drawn under it, for its part's frames
raea Transition its child coming in over its part's first frames and going out over its last
raea Overlay children only in a render asked for that overlay
raea Region a box at a named band, clear of the face perception found