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.

TL7g: a clip's own Adjust in the timeline. sdk/timeline adjust.ts: a clip's Adjust as its props (adjustBrightness..adjustGrain, 0 as shot; ADJUST_PROPS), read as the kinds not 0 (adjustOf), written whole (adjustProps), its errors, and the preview's look (adjustLook: the filter's id and steps, the vignette's background). read.ts: a sequence's <Nudge adjust> read back as the clip's props and written by the set edit with the rest of its placement; each kind keyed as adjust.<kind>. The app (raea-feed PR #19 8cab9ce): the row's adjust panel of twelve sliders, keyed, with reset; the picture wearing it as one filter after the key and a vignette layer; the host reading and writing <Nudge adjust>; Send saying it. Tests: 106 timeline SDK; 40 browser tests in Chrome, 38 of 40 in raea's window, two skipping themselves; the manual regenerated; the inspector bullet's Not yet without Adjust

shinyobjectz494b39544294
diff --git a/docs/manual/reference/sdk/editor.md b/docs/manual/reference/sdk/editor.md
index 8384c7cf..dd118663 100644
--- a/docs/manual/reference/sdk/editor.md
+++ b/docs/manual/reference/sdk/editor.md
@@ -18,13 +18,47 @@ built, edited and undone.
<!-- generated:begin by tools/manual-ref/sdk.ts from the SDK's exports and doc comments; edit outside this block -->
```ts
-import { ahead, animStyle, apply, applyAll } from "raea/editor"
+import { ADJUST_KINDS, ADJUST_PROP_LIST, ADJUST_PROPS, adjustError } from "raea/editor"
```
-`raea/editor` exports 59 functions, 24 values, 42 types. Bevy's counterpart: `raea's own; Bevy has no timeline editor`. Source: [sdk/raea/src/editor.ts](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/editor.ts).
+`raea/editor` exports 63 functions, 28 values, 45 types. Bevy's counterpart: `raea's own; Bevy has no timeline editor`. Source: [sdk/raea/src/editor.ts](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/editor.ts).
## Functions
+### `adjustError`
+
+What is wrong with a clip's adjustment props as they stand, or undefined: a value out of its range.
+
+```ts
+function adjustError(props?: Props): string | undefined
+```
+
+### `adjustLook`
+
+How the editor's preview draws a clip's adjustment on its picture, as <Nudge adjust> draws it: its SVG filter's
+id and steps (to put beside the picture), and its vignette's background (a layer over the picture). A wrong one
+draws nothing rather than throwing in the editor.
+
+```ts
+function adjustLook(props: Props | undefined, seed?: number): { filter?: { id: string; steps: FilterStep[]; } | undefined; vignette?: string; }
+```
+
+### `adjustOf`
+
+A clip's adjustment read from its props: the kinds that aren't 0.
+
+```ts
+function adjustOf(props?: Props): Partial<Record<"saturation" | "fade" | "brightness" | "contrast" | "exposure" | "sharpen" | "highlights" | "shadows" | "temperature" | "tint" | "vignette" | "grain", number>>
+```
+
+### `adjustProps`
+
+An adjustment as a clip's props, to three places: every kind, 0 for what it hasn't got, so a set puts it whole.
+
+```ts
+function adjustProps(a: Partial<Record<"saturation" | "fade" | "brightness" | "contrast" | "exposure" | "sharpen" | "highlights" | "shadows" | "temperature" | "tint" | "vignette" | "grain", number>>): Props
+```
+
### `ahead`
The ranges to draw next while there is time: what isn't kept from the playhead on, nearest first, each
@@ -533,6 +567,20 @@ function without(ranges: Range[], cut: Range[]): Range[]
## Values
+### `ADJUST_KINDS`
+
+### `ADJUST_PROP_LIST`
+
+The clip props an adjustment is held in.
+
+### `ADJUST_PROPS`
+
+Each adjustment as a clip's prop: brightness is adjustBrightness.
+
+### `ADJUSTS`
+
+CapCut's Adjust, in its order: each from -1 to 1 (0 as shot), but sharpen, fade, vignette and grain, from 0.
+
### `BLEND_KINDS`
### `BLENDS`
@@ -639,6 +687,22 @@ What one plugin adds.
| `tools` | `Preset[]` | tools of its own: presets put on the picked clips |
| `snaps` | `SnapGrid[]` | marks edges snap to: grids in seconds |
+### `Adjust`
+
+A part's adjustments, each 0 (or left out) as shot: brightness, contrast, saturation, exposure, highlights,
+shadows, temperature (warm above 0) and tint (magenta above 0) from -1 to 1; sharpen, fade, vignette and grain from
+0 to 1.
+
+```ts
+type Adjust = Partial<Record<AdjustKind, number>>
+```
+
+### `AdjustKind`
+
+```ts
+type AdjustKind = (typeof ADJUSTS)[number]["kind"]
+```
+
### `Anim`
How a clip comes in or goes out on its own: a transition's kind over its own first or last frames.
@@ -798,6 +862,16 @@ from `from` (amount 0, where it changes nothing) to `to` (amount 1), with its un
type EffectPart = [fn: string, from: number, to: number, unit?: string]
```
+### `FilterStep`
+
+One step of an SVG filter: its tag and its attributes, so React and the DOM can each make it.
+
+| Field | Type | What it is |
+| --- | --- | --- |
+| `tag` (required) | `"feComponentTransfer" \| "feFuncR" \| "feFuncG" \| "feFuncB" \| "feColorMatrix" \| "feConvol…` | – |
+| `attrs` (required) | `Record<string, string>` | – |
+| `children` | `FilterStep[]` | a component transfer's functions |
+
### `Frames`
A count of frames, always whole.
@@ -926,6 +1000,7 @@ A sequence's still placement: its <Nudge>'s props (sdk/video nudge.tsx). `crop`
| `mask` | `Mask` | what of it is seen: a shape in shares of the frame |
| `blend` | `Blend` | how it is drawn over what is under it, normal when not said |
| `chroma` | `ChromaKey` | a colour taken out of it |
+| `adjust` | `Adjust` | its own Adjust, each kind not 0 |
### `SeqRow`
diff --git a/docs/manual/reference/sdk/index.md b/docs/manual/reference/sdk/index.md
index f2698836..4e62a090 100644
--- a/docs/manual/reference/sdk/index.md
+++ b/docs/manual/reference/sdk/index.md
@@ -61,7 +61,7 @@ Footage, pictures, sound, words and colour, and the timeline they are edited on.
| [`raea/image`](image.md) | Pictures on the page and in the world, and texture atlases packed from them. | 3 components, 1 class, 5 types |
| [`raea/asset`](asset.md) | Files the project holds and assets made for it: staticFile, generated sound and music, and glTF bytes. | 9 functions, 1 value, 8 types |
| [`raea/color`](color.md) | Bevy's colour types: Srgba, LinearRgba, Hsla, Oklab, Oklch and the rest, with their conversions. | 2 functions, 7 classes |
-| [`raea/editor`](editor.md) | The timeline the feed edits a film, a scene or a sound on, as data: tracks, clips, keys and markers, every edit an operation with its inverse, a film's scenes read in (fromRender) and its cut read back out as segments (segmentsOf). No React and no DOM: an agent's script, the app's host and a test use the same model the app's timeline does. | 59 functions, 24 values, 42 types |
+| [`raea/editor`](editor.md) | The timeline the feed edits a film, a scene or a sound on, as data: tracks, clips, keys and markers, every edit an operation with its inverse, a film's scenes read in (fromRender) and its cut read back out as segments (segmentsOf). No React and no DOM: an agent's script, the app's host and a test use the same model the app's timeline does. | 63 functions, 28 values, 45 types |
## 3D
diff --git a/docs/timeline.feature b/docs/timeline.feature
index 8fded029..b6f5ee3c 100644
--- a/docs/timeline.feature
+++ b/docs/timeline.feature
@@ -61,9 +61,10 @@ Feature: The timeline SDK (0.1.5): CapCut's timeline, on the composition, in the
style, effects, bubbles, animation, and its words read aloud.
Here 11-14: Basic but stabilise (TL3h, TL5), Mask, chroma key and Blend (TL7f), Animation (TL7d, TL7e), Speed
(TL6), Audio's volume and fades (TL8a), Text's words, styles and captions (TL7c), Adjust as effect clips over a
- span (TL7b, raea's ten). Not yet: stabilise, auto and brushed cutout, the key colour picked from the picture,
- Retouch, Adjust as the clip's own sliders, noise reduction, the voice changer, text read aloud, and a mask's
- handles dragged on the picture (its values are typed and slid in the row).
+ span (TL7b, raea's ten) and as the clip's own twelve sliders (TL7g), every number of these keyed (TL5a). Not
+ yet: stabilise, auto and brushed cutout, the key colour picked from the picture, Retouch, noise reduction, the
+ voice changer, text read aloud, a mask's handles dragged on the picture (its values are typed and slid in the
+ row), and a vignette on a file from Media laid over the film (its other adjustments are drawn).
The model this file sets:
1. One timeline model, in an SDK (sdk/timeline, TypeScript, no React, no DOM): tracks, clips, keys, markers, and
@@ -86,21 +87,22 @@ Feature: The timeline SDK (0.1.5): CapCut's timeline, on the composition, in the
Status, 11-13 (the first day). On raea main: sdk/timeline (model, ops with inverses, compound clips, keys and
bezier easing, speed curves, freeze frames and reversed footage, snapping, the frame store's decisions, live
playback's mapping, readers and writers for a composition's sequences (its footage and sound, its text, its
- effects, a recording, a project's file), a film's scenes and a sound's tracks, the palette a plugin adds to; 77
+ effects, a recording, a project's file), a film's scenes and a sound's tracks, the palette a plugin adds to, a clip's cutout and Adjust; 106
tests), and in
- sdk/video <Nudge keys mask blend chroma> (keys for the placement and, by a dotted name, a mask's, a key's and a
- crop's numbers; cutout.ts: a mask's six shapes, CSS's blend modes, a chroma key), <Transition in out combo> (fade, slide, wipe, zoom; a Combo's seven waves), <Effect kind amount in out> (blur, mono,
+ sdk/video <Nudge keys mask blend chroma adjust> (keys for the placement and, by a dotted name, a mask's, a key's, a
+ crop's and an adjustment's numbers; cutout.ts: a mask's six shapes, CSS's blend modes, a chroma key; adjust.ts:
+ CapCut's twelve adjustments as one SVG filter and a vignette layer), <Transition in out combo> (fade, slide, wipe, zoom; a Combo's seven waves), <Effect kind amount in out> (blur, mono,
sepia, vivid, faded, contrast, bright, dark, invert, hue: a filter on the picture under it) and a <Video>'s or
an <Audio>'s speedCurve (the mixer carries its sound through the changing rate as one voice). In raea-feed, draft
- PR #19: the new timeline is the timeline (localStorage raea.timeline-sdk = 0 brings the old strip back); 39 browser
- tests in Chrome, all passing; in a headless raea window 37 of the 39 pass and two skip themselves there with their
+ PR #19: the new timeline is the timeline (localStorage raea.timeline-sdk = 0 brings the old strip back); 40 browser
+ tests in Chrome, all passing; in a headless raea window 38 of the 40 pass and two skip themselves there with their
reason (the voice test, which would ask for this Mac's microphone, and TL10d, whose film the window decodes itself,
so no route can hold its data), among them TL9c, an agent's edits, a composition's every edit, freeze and reverse, mirror and
crop, effects, groups and compounds, the posted item's, a plugin's effect, text style, tool and snap grid, saved
curves, Settings' kept frames, both kinds of sound taken out, the switcher, the export range, media added, the
Option keys, captions made from what is said, a clip's In, Out and Combo, and its mask, blend and chroma key (whose
sliders are a track of their own, as the volume's is: the window doesn't move a range input), their numbers and the
- crop's sides keyed (TL5a). The window runner (blitz/pw.mjs) answers routes one at a time in the order asked, keeps a reload's
+ crop's sides keyed (TL5a), and its own Adjust (TL7g). The window runner (blitz/pw.mjs) answers routes one at a time in the order asked, keeps a reload's
address and each test's storage, and has keyboard down and up, toBeFocused and waitForResponse. The timeline's keys
follow the pointer over it, not :hover, which raea's window doesn't match for a script, so there they only worked
after a click in the timeline:
diff --git a/sdk/timeline/src/adjust.ts b/sdk/timeline/src/adjust.ts
new file mode 100644
index 00000000..4d9e2053
--- /dev/null
+++ b/sdk/timeline/src/adjust.ts
@@ -0,0 +1,47 @@
+// A clip's own Adjust (docs/timeline.feature TL7g; CapCut's Adjust tab) as its props: one a kind (brightness is
+// adjustBrightness), 0 as shot, each keyed as any number is (TL5a). The preview's look and a composition's
+// <Nudge adjust> are drawn by sdk/video adjust.ts, one SVG filter and a vignette layer.
+import { ADJUST_KINDS, ADJUSTS, adjustError as error, adjustId, adjustSteps, vignetteStyle, type Adjust, type AdjustKind, type FilterStep } from "@raea/video/adjust"
+import type { Value } from "./model"
+
+export { ADJUST_KINDS, ADJUSTS, type Adjust, type AdjustKind, type FilterStep }
+
+type Props = Record<string, Value | boolean>
+
+/** Each adjustment as a clip's prop: brightness is adjustBrightness. */
+export const ADJUST_PROPS = Object.fromEntries(ADJUST_KINDS.map((k) => [k, `adjust${k[0].toUpperCase()}${k.slice(1)}`])) as Record<AdjustKind, string>
+/** The clip props an adjustment is held in. */
+export const ADJUST_PROP_LIST: string[] = Object.values(ADJUST_PROPS)
+
+/** A clip's adjustment read from its props: the kinds that aren't 0. */
+export function adjustOf(props: Props = {}): Adjust {
+ return Object.fromEntries(ADJUST_KINDS.flatMap((k) => {
+ const v = props[ADJUST_PROPS[k]]
+ return typeof v === "number" && Number.isFinite(v) && v !== 0 ? [[k, v]] : []
+ })) as Adjust
+}
+
+/** An adjustment as a clip's props, to three places: every kind, 0 for what it hasn't got, so a set puts it whole. */
+export function adjustProps(a: Adjust): Props {
+ return Object.fromEntries(ADJUST_KINDS.map((k) => [ADJUST_PROPS[k], Math.round((a[k] ?? 0) * 1000) / 1000]))
+}
+
+/** What is wrong with a clip's adjustment props as they stand, or undefined: a value out of its range. */
+export function adjustError(props: Props = {}): string | undefined {
+ for (const k of ADJUST_KINDS) {
+ const v = props[ADJUST_PROPS[k]]
+ if (v !== undefined && typeof v !== "number") return `an adjust's ${k} is a number, got ${JSON.stringify(v)}`
+ }
+ return error(adjustOf(props))
+}
+
+/** How the editor's preview draws a clip's adjustment on its picture, as <Nudge adjust> draws it: its SVG filter's
+ * id and steps (to put beside the picture), and its vignette's background (a layer over the picture). A wrong one
+ * draws nothing rather than throwing in the editor. */
+export function adjustLook(props: Props | undefined, seed = 0): { filter?: { id: string; steps: FilterStep[] }; vignette?: string } {
+ const a = adjustOf(props)
+ if (error(a)) return {}
+ const steps = adjustSteps(a, seed)
+ const v = vignetteStyle(a.vignette ?? 0)
+ return { ...(steps.length && { filter: { id: adjustId(a, seed), steps } }), ...(v && { vignette: v.background }) }
+}
diff --git a/sdk/timeline/src/index.ts b/sdk/timeline/src/index.ts
index 581cf57c..3d7f46ce 100644
--- a/sdk/timeline/src/index.ts
+++ b/sdk/timeline/src/index.ts
@@ -12,4 +12,5 @@ export * from "./play"
export * from "./captions"
export * from "./anim"
export * from "./cutout"
+export * from "./adjust"
export * from "./sounds"
diff --git a/sdk/timeline/src/read.ts b/sdk/timeline/src/read.ts
index a18b8669..545eec5c 100644
--- a/sdk/timeline/src/read.ts
+++ b/sdk/timeline/src/read.ts
@@ -7,6 +7,7 @@ import { apply, type Op } from "./ops"
import { EFFECTS, type EffectPart, type TextStyle, textStyleError } from "./registry"
import { COMBO_KINDS, TRANSITION_KINDS } from "@raea/video/edges"
import { CUTOUT_PROPS, cutoutError, cutoutOf, cutoutProps, KEY_PROPS, MASK_PROPS, type Blend, type ChromaKey, type Mask } from "./cutout"
+import { ADJUST_KINDS, ADJUST_PROP_LIST, ADJUST_PROPS, adjustError, adjustOf, type Adjust } from "./adjust"
/** A text clip's style, kept in its props as JSON: read back when it is well formed. */
export function textStyleOf(v: unknown): TextStyle | undefined {
@@ -100,6 +101,8 @@ export interface SeqLook {
blend?: Blend
/** a colour taken out of it (TL7f) */
chroma?: ChromaKey
+ /** its own Adjust, each kind not 0 (TL7g) */
+ adjust?: Adjust
}
const CROPS = ["cropLeft", "cropTop", "cropRight", "cropBottom"]
/** The host's edit to a sequence: its new span, a split, a delete. */
@@ -150,6 +153,7 @@ export const KEY_NAMES: Record<string, string> = {
...Object.fromEntries((["x", "y", "w", "h", "rotate", "feather", "round"] as const).map((k) => [MASK_PROPS[k], `mask.${k}`])),
...Object.fromEntries((["strength", "shadow"] as const).map((k) => [KEY_PROPS[k], `chroma.${k}`])),
...Object.fromEntries(CROPS.map((k) => [k, `crop.${k.slice(4).toLowerCase()}`])),
+ ...Object.fromEntries(ADJUST_KINDS.map((k) => [ADJUST_PROPS[k], `adjust.${k}`])),
}
/** The clip props a sequence keys. */
export const KEYABLE = Object.keys(KEY_NAMES)
@@ -162,6 +166,7 @@ const lookProps = (l: SeqLook): Record<string, Value | boolean> => ({
...(l.mirror && { mirror: true }),
...(l.crop && Object.fromEntries(CROPS.map((k, n) => [k, l.crop![n]]))),
...((l.mask || l.blend || l.chroma) && cutoutProps(l)),
+ ...(l.adjust && Object.fromEntries(Object.entries(l.adjust).map(([k, v]) => [ADJUST_PROPS[k as keyof Adjust], v]))),
})
// the edits to later elements first (an edit that adds or removes an element moves the places after it)
const later = (a: SeqEdit, b: SeqEdit) => ("i" in b ? b.i : 0) - ("i" in a ? a.i : 0)
@@ -314,19 +319,20 @@ export function seqEdits(t: Timeline, op: Op): SeqEdit[] | { why: string } {
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 }) }))
}
- // how a sequence is placed (moved, scaled, turned, faded, mirrored, cropped, masked, blended, keyed): its <Nudge>'s still props
+ // how a sequence is placed (moved, scaled, turned, faded, mirrored, cropped, masked, blended, keyed, adjusted): its <Nudge>'s still props
if (only.length === 1 && only[0] === "props" && find(t, op.id)?.clip.kind !== "effect") {
- const bad = Object.keys(op.set.props!).filter((k) => !KEYED.includes(k) && k !== "mirror" && !CROPS.includes(k) && !CUTOUT_PROPS.includes(k))
- if (bad.length) return { why: `a sequence is placed by its ${[...KEYED, "mirror", "crop", "mask", "blend", "chroma"].join(", ")}: ${bad.join(", ")} ${bad.length > 1 ? "are" : "is"} its own code's` }
+ const bad = Object.keys(op.set.props!).filter((k) => !KEYED.includes(k) && k !== "mirror" && !CROPS.includes(k) && !CUTOUT_PROPS.includes(k) && !ADJUST_PROP_LIST.includes(k))
+ if (bad.length) return { why: `a sequence is placed by its ${[...KEYED, "mirror", "crop", "mask", "blend", "chroma", "adjust"].join(", ")}: ${bad.join(", ")} ${bad.length > 1 ? "are" : "is"} its own code's` }
const after = apply(t, op)
if (!after.ok) return { why: after.why }
const p = find(after.timeline, op.id)?.clip.props ?? {}
const num = (k: string) => (typeof p[k] === "number" && Number.isFinite(p[k]) ? Math.round((p[k] as number) * 1000) / 1000 : undefined)
if ((num("scale") ?? 1) <= 0) return { why: "a scale is above 0" }
- const cut = cutoutError(p)
+ const cut = cutoutError(p) ?? adjustError(p)
if (cut) return { why: cut }
const crop = CROPS.map((k) => Math.min(0.9, Math.max(0, num(k) ?? 0))) as [number, number, number, number]
- const look: SeqLook = { ...Object.fromEntries(KEYED.flatMap((k) => (num(k) === undefined ? [] : [[k, num(k)]]))), ...(p.mirror === true && { mirror: true }), ...(crop.some((v) => v > 0) && { crop }), ...cutoutOf(p) }
+ const adjust = adjustOf(p)
+ const look: SeqLook = { ...Object.fromEntries(KEYED.flatMap((k) => (num(k) === undefined ? [] : [[k, num(k)]]))), ...(p.mirror === true && { mirror: true }), ...(crop.some((v) => v > 0) && { crop }), ...cutoutOf(p), ...(Object.keys(adjust).length && { adjust }) }
return each([op.id], (r) => ({ op: "nudge", i: r.i, look }))
}
// its In and Out animations (TL7d) and its Combo (TL7e): its <Transition>'s edges, as a cut's transition writes them
diff --git a/sdk/timeline/test/adjust.test.ts b/sdk/timeline/test/adjust.test.ts
new file mode 100644
index 00000000..1b55a0c9
--- /dev/null
+++ b/sdk/timeline/test/adjust.test.ts
@@ -0,0 +1,59 @@
+// A clip's own Adjust (docs/timeline.feature TL7g): its props, the preview's look, and a composition's <Nudge adjust>.
+import { describe, expect, test } from "bun:test"
+import { ADJUST_PROPS, adjustError, adjustLook, adjustOf, adjustProps, fromSequences, KEY_NAMES, seqEdits } from "../src"
+
+describe("TL7g: a clip's Adjust is its props", () => {
+ test("one prop a kind, read back as the kinds not 0, written whole so a set puts it all", () => {
+ expect(ADJUST_PROPS.brightness).toBe("adjustBrightness")
+ expect(adjustOf({ adjustContrast: 0.3, adjustSaturation: 0, adjustGrain: 0.5, scale: 2 })).toEqual({ contrast: 0.3, grain: 0.5 })
+ const props = adjustProps({ contrast: 0.3333 })
+ expect(Object.keys(props)).toHaveLength(12)
+ expect(props.adjustContrast).toBe(0.333)
+ expect(props.adjustVignette).toBe(0)
+ expect(adjustOf(adjustProps({}))).toEqual({})
+ })
+
+ test("what is wrong is said: a value out of its range, or not a number", () => {
+ expect(adjustError({ adjustSharpen: -0.2 })).toMatch(/sharpen is from 0 to 1/)
+ expect(adjustError({ adjustContrast: "lots" })).toMatch(/contrast is a number/)
+ expect(adjustError({ adjustContrast: -1, adjustFade: 1 })).toBeUndefined()
+ })
+
+ test("the preview's look: the filter's id and steps, and the vignette's background; nothing for a wrong one", () => {
+ const look = adjustLook({ adjustContrast: 0.5, adjustVignette: 0.5 })
+ expect(look.filter?.id).toBe("raea-adjust-con50")
+ expect(look.filter?.steps[0].tag).toBe("feComponentTransfer")
+ expect(look.vignette).toContain("radial-gradient")
+ expect(adjustLook({ adjustVignette: 0.5 }).filter).toBeUndefined()
+ expect(adjustLook({ adjustContrast: 9 })).toEqual({})
+ expect(adjustLook(undefined)).toEqual({})
+ })
+
+ test("each kind is keyed as adjust.<kind>", () => {
+ expect(KEY_NAMES.adjustTemperature).toBe("adjust.temperature")
+ })
+})
+
+describe("TL7g: in a composition it is the sequence's <Nudge adjust>", () => {
+ const row = { i: 0, name: "Sequence", label: "First scene", from: 0, to: 90, lane: 0 }
+
+ test("read back as the clip's props, beside its placement", () => {
+ const t = fromSequences([{ ...row, look: { scale: 1.2, adjust: { contrast: 0.3, vignette: 0.6 } } }], 30)
+ expect(t.tracks[0].clips[0].props).toEqual({ scale: 1.2, adjustContrast: 0.3, adjustVignette: 0.6 })
+ })
+
+ test("set on a clip, the whole placement goes to the host with its adjustment; all 0, it goes", () => {
+ const t = fromSequences([{ ...row, look: { scale: 1.2 } }], 30)
+ expect(seqEdits(t, { op: "set", id: "seq-0", set: { props: { adjustExposure: 0.4 } } })).toEqual([{ op: "nudge", i: 0, look: { scale: 1.2, adjust: { exposure: 0.4 } } }])
+ const had = fromSequences([{ ...row, look: { scale: 1.2, adjust: { exposure: 0.4 } } }], 30)
+ expect(seqEdits(had, { op: "set", id: "seq-0", set: { props: adjustProps({}) } })).toEqual([{ op: "nudge", i: 0, look: { scale: 1.2 } }])
+ expect(seqEdits(t, { op: "set", id: "seq-0", set: { props: { adjustGrain: 3 } } })).toEqual({ why: "an adjust's grain is from 0 to 1, got 3" })
+ })
+
+ test("a key on an adjustment is its <Nudge keys> by adjust.<kind>, and read back", () => {
+ const t = fromSequences([{ ...row }], 30)
+ expect(seqEdits(t, { op: "key", id: "seq-0", prop: "adjustSaturation", at: 10, value: -0.5 })).toEqual([{ op: "keys", i: 0, keys: { "adjust.saturation": [[10, -0.5]] } }])
+ const read = fromSequences([{ ...row, keys: { "adjust.saturation": [[0, 0], [30, -1]] } }], 30)
+ expect(read.tracks[0].clips[0].keys).toEqual({ adjustSaturation: [{ at: 0, value: 0 }, { at: 30, value: -1 }] })
+ })
+})