Skip to content

The VS Code of video editing, built for agents.

TypeScript

Refactor Mask Terminology and Functionality

konstantin-paulus4d5d9fc780b8
diff --git a/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsx b/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsx
index 68a31de0..3a18c502 100644
--- a/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/effects-inspector.tsx
@@ -76,7 +76,7 @@ export function EffectsInspector(props: EffectsInspectorProps) {
const option = createMemo(() => effectOption(effect()?.type));
const value = useDerived(() => props.effect.get(Computed)?.value ?? 0);
- const masks = useDerived(() => props.effect.get(Cache)?.mattes ?? NO_MASKS);
+ const masks = useDerived(() => props.effect.get(Cache)?.masks ?? NO_MASKS);
const isVideo = useDerived(() => {
const node = getParentNode(props.effect);
diff --git a/apps/web/src/components/sidebar-right/inspector/object-mask.tsx b/apps/web/src/components/sidebar-right/inspector/object-mask.tsx
index 62845f10..82b71af3 100644
--- a/apps/web/src/components/sidebar-right/inspector/object-mask.tsx
+++ b/apps/web/src/components/sidebar-right/inspector/object-mask.tsx
@@ -25,7 +25,7 @@ import { SliderInput } from "@/components/ui/slider-input";
import { Switch, SwitchControl, SwitchInput, SwitchThumb } from "@/components/ui/switch";
import { useHas, useTrait, useWorld } from "@diffusionstudio/koota-solid";
import {
- AssetId, Computed, Effect, Hidden, Library, Matte, Name, VideoDecoderHandle, getParentNode,
+ AssetId, Computed, Effect, Hidden, Library, Mask, Name, VideoDecoderHandle, getParentNode,
} from "@diffusionstudio/runtime";
import { useDerived, useEditor } from "@/engine/hooks";
import { syncKeyframe } from "@/engine/keyframes";
@@ -276,7 +276,7 @@ export function ObjectMaskInspector(props: ObjectMaskInspectorProps) {
const editor = useEditor();
const hidden = useHas(() => props.mask, Hidden);
- const matte = useTrait(() => props.mask, Matte);
+ const mask = useTrait(() => props.mask, Mask);
const maskAsset = (): MaskAsset | null => {
const asset = world.get(Library)?.get(props.mask.get(AssetId)?.value ?? "");
@@ -413,7 +413,7 @@ export function ObjectMaskInspector(props: ObjectMaskInspectorProps) {
</ControlRow>
<ControlRow label="Smoothing">
<SliderInput
- value={Math.round((matte()?.smoothing ?? DEFAULT_MASK_SMOOTHING) * 100)}
+ value={Math.round((mask()?.smoothing ?? DEFAULT_MASK_SMOOTHING) * 100)}
min={0}
max={100}
onChange={editSmoothing}
@@ -421,7 +421,7 @@ export function ObjectMaskInspector(props: ObjectMaskInspectorProps) {
/>
</ControlRow>
<ControlRow label="Invert">
- <Switch checked={matte()?.inverted ?? false} onChange={editInverted}>
+ <Switch checked={mask()?.inverted ?? false} onChange={editInverted}>
<SwitchInput />
<SwitchControl variant="compact">
<SwitchThumb variant="compact" />
diff --git a/apps/web/src/engine/object-mask/commit.tsx b/apps/web/src/engine/object-mask/commit.tsx
index e7062a5a..ab4a47de 100644
--- a/apps/web/src/engine/object-mask/commit.tsx
+++ b/apps/web/src/engine/object-mask/commit.tsx
@@ -67,7 +67,7 @@ export async function commitObjectMask(world: World, track: ObjectTrack): Promis
{mask()}
</EffectElement>
));
- return effect?.get(Cache)?.mattes[0] ?? null;
+ return effect?.get(Cache)?.masks[0] ?? null;
}
/** A mask file of tracked frames, on a `grid` square, over footage of `size`, one a frame at `frameRate`. */
diff --git a/apps/web/src/engine/object-mask/copy.tsx b/apps/web/src/engine/object-mask/copy.tsx
index 04185b46..7901be01 100644
--- a/apps/web/src/engine/object-mask/copy.tsx
+++ b/apps/web/src/engine/object-mask/copy.tsx
@@ -50,7 +50,7 @@ export function listObjectMasks(world: World, clip: Entity): ObjectMaskSource[]
/** Whether `effect` already has a mask of the same frames as `source`. */
export function effectHasObjectMask(effect: Entity, source: ObjectMaskSource): boolean {
- return (effect.get(Cache)?.mattes ?? []).some((mask) => mask.get(AssetId)?.value === source.asset.id);
+ return (effect.get(Cache)?.masks ?? []).some((mask) => mask.get(AssetId)?.value === source.asset.id);
}
/**
@@ -76,7 +76,7 @@ export function copyObjectMask(world: World, effect: Entity, source: ObjectMaskS
function featherOf(effect: Entity, source: ObjectMaskSource): number | undefined {
const node = getParentNode(effect);
for (const sibling of node?.get(Cache)?.effects ?? [effect]) {
- for (const mask of sibling.get(Cache)?.mattes ?? []) {
+ for (const mask of sibling.get(Cache)?.masks ?? []) {
if (mask.get(AssetId)?.value === source.asset.id) return mask.get(Blur)?.value;
}
}
diff --git a/apps/web/src/engine/object-mask/overlay.ts b/apps/web/src/engine/object-mask/overlay.ts
index ca4bfe50..86b3e2cb 100644
--- a/apps/web/src/engine/object-mask/overlay.ts
+++ b/apps/web/src/engine/object-mask/overlay.ts
@@ -153,7 +153,7 @@ function drawMask(ctx: Ctx2D, rect: VideoRect, mask: Sam2Mask | MaskFrame, size:
// The outline is traced in grid pixels and placed on the device, then
// filled and stroked there, so the edge is smooth and the line keeps its
- // width at any zoom. It is the edge the matte is cut along.
+ // width at any zoom. It is the edge the mask is cut along.
const outline = new Path2D();
const grid = new DOMMatrix([mat.a, mat.b, mat.c, mat.d, mat.e, mat.f])
.translate(rect.x, rect.y)
diff --git a/packages/jsx/src/types.ts b/packages/jsx/src/types.ts
index 730f9623..9188c69a 100644
--- a/packages/jsx/src/types.ts
+++ b/packages/jsx/src/types.ts
@@ -616,7 +616,7 @@ export type EffectProps = Pick<CompositeProps, "hidden"> & {
* one effect intersect. Without a `src` a mask does nothing.
*/
export type MaskProps = Pick<CompositeProps, "hidden"> & TrackChildren & {
- /** The matte's frames: a directory of numbered images whose alpha is the mask. */
+ /** The mask's frames: a directory of numbered images whose alpha is the mask. */
src?: string;
/** The parent's source time the first frame belongs to, so the frames stay on the footage they were made from whatever the trim. Default 0. */
sourceIn?: Time;
diff --git a/packages/reconciler/src/document.ts b/packages/reconciler/src/document.ts
index 0abdb589..cc3d37e9 100644
--- a/packages/reconciler/src/document.ts
+++ b/packages/reconciler/src/document.ts
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-import { Active, AdjustmentLayer, Animation, AnimationPhase, AnimationType, appendChild, AssetId, Audio, Background, bindAsset, BlendMode, BlendModeType, Blur, Caption, CaptionAlign, CAPTION_PRESET_FILLS, CAPTION_PRESET_STYLES, CaptionType, Chars, ClipHeight, ClipsContent, Computed, Constraint, ConstraintCache, ConstraintType, CornerRadius, createEntity, DEFAULT_BACKGROUND, Color, ColorStop, Delay, Effect, EffectType, Expanded, FontStyle, FramePromises, FrameRate, Generating, GenerationRequest, getActiveEntity, Loop, LoadRequest, Matte, Geometry, GeometryType, getEntityTree, getParentEntity, getParentNode, Hidden, Host, IsClipPath, isText, ItemIndex, KeepAspectRatio, Keyframe, KeyframeTrack, MixedCornerRadius, Mode, Muted, Name, Offset, Opacity, Paint, PaintType, parseColor, PendingSource, PendingSync, Playback, PlaybackRate, Position, removeChild, RenderSurface, resizeEntity, Scale, ScaleMode, ScaleModeType, secondsToFrames, getAsset, getEntityChildren, Group, Sequential, Shader, Size, Stage, Root, Rotation, Scene, Selected, Shadow, Source, SourceFrameRate, setCameraMatrix, setPlayhead, setTimelineView, Stroke, StrokeCap, StrokeJoin, StrokeStyle, SyncRequest, TextAlign, TextBaseline, TextCase, TextRange, TextStyle, TranscriptionRequest, Transition, TransitionType, Trim, UniformScale, Volume, Workarea } from '@diffusionstudio/runtime';
+import { Active, AdjustmentLayer, Animation, AnimationPhase, AnimationType, appendChild, AssetId, Audio, Background, bindAsset, BlendMode, BlendModeType, Blur, Caption, CaptionAlign, CAPTION_PRESET_FILLS, CAPTION_PRESET_STYLES, CaptionType, Chars, ClipHeight, ClipsContent, Computed, Constraint, ConstraintCache, ConstraintType, CornerRadius, createEntity, DEFAULT_BACKGROUND, Color, ColorStop, Delay, Effect, EffectType, Expanded, FontStyle, FramePromises, FrameRate, Generating, GenerationRequest, getActiveEntity, Loop, LoadRequest, Mask, Geometry, GeometryType, getEntityTree, getParentEntity, getParentNode, Hidden, Host, IsClipPath, isText, ItemIndex, KeepAspectRatio, Keyframe, KeyframeTrack, MixedCornerRadius, Mode, Muted, Name, Offset, Opacity, Paint, PaintType, parseColor, PendingSource, PendingSync, Playback, PlaybackRate, Position, removeChild, RenderSurface, resizeEntity, Scale, ScaleMode, ScaleModeType, secondsToFrames, getAsset, getEntityChildren, Group, Sequential, Shader, Size, Stage, Root, Rotation, Scene, Selected, Shadow, Source, SourceFrameRate, setCameraMatrix, setPlayhead, setTimelineView, Stroke, StrokeCap, StrokeJoin, StrokeStyle, SyncRequest, TextAlign, TextBaseline, TextCase, TextRange, TextStyle, TranscriptionRequest, Transition, TransitionType, Trim, UniformScale, Volume, Workarea } from '@diffusionstudio/runtime';
import { DEFAULT_MASK_SMOOTHING } from '@diffusionstudio/assets';
import { LOOP_ATTR, parseTime, SOURCE_ATTR } from '@diffusionstudio/jsx';
import { createSignal } from 'solid-js';
@@ -670,7 +670,7 @@ export class RuntimeDocument implements ProjectDocument<SceneNode> {
}
case 'mask': {
entity = createEntity(this.world);
- entity.add(Matte);
+ entity.add(Mask);
break;
}
case 'animation': {
@@ -972,14 +972,14 @@ export class RuntimeDocument implements ProjectDocument<SceneNode> {
return;
}
case 'inverted': {
- if (!entity.has(Matte)) return;
- entity.set(Matte, { inverted: value === true });
+ if (!entity.has(Mask)) return;
+ entity.set(Mask, { inverted: value === true });
return;
}
case 'smoothing': {
- if (!entity.has(Matte)) return;
+ if (!entity.has(Mask)) return;
const amount = toNumber(value) ?? DEFAULT_MASK_SMOOTHING;
- entity.set(Matte, { smoothing: Math.min(1, Math.max(0, amount)) });
+ entity.set(Mask, { smoothing: Math.min(1, Math.max(0, amount)) });
return;
}
case 'keepAspectRatio': {
@@ -1150,10 +1150,10 @@ export class RuntimeDocument implements ProjectDocument<SceneNode> {
case 'end':
case 'sourceIn':
case 'sourceOut': {
- if (entity.has(Matte)) {
- // A matte's frames start at this source time of its parent.
+ if (entity.has(Mask)) {
+ // A mask's frames start at this source time of its parent.
if (name === 'sourceIn') {
- entity.set(Matte, { offset: this.toFrames(toSeconds(value) ?? 0) })
+ entity.set(Mask, { offset: this.toFrames(toSeconds(value) ?? 0) })
};
return;
}
diff --git a/packages/runtime/src/actions/cache.ts b/packages/runtime/src/actions/cache.ts
index 562a92c0..88bb7722 100644
--- a/packages/runtime/src/actions/cache.ts
+++ b/packages/runtime/src/actions/cache.ts
@@ -11,7 +11,7 @@ import { Not, Or } from 'koota';
import { store } from '../world/store';
import {
ChildOf, Cache,
- Geometry, Group, AdjustmentLayer, IsClipPath, Matte, Paint, Stroke, Shadow, Effect,
+ Geometry, Group, AdjustmentLayer, IsClipPath, Mask, Paint, Stroke, Shadow, Effect,
TextRange, KeyframeTrack, Keyframe, Animation,
} from '../traits';
import { isStage } from '../queries/predicates';
@@ -48,8 +48,8 @@ export function rebuildCaches(world: World, entity: Entity, parent: Entity | nul
.sort(sortByItemIndex);
}
- if (entity.has(Matte)) {
- cache.mattes[pid] = collect(Matte, ChildOf(parent))
+ if (entity.has(Mask)) {
+ cache.masks[pid] = collect(Mask, ChildOf(parent))
.sort(sortByItemIndex);
}
@@ -105,7 +105,7 @@ export function rebuildCaches(world: World, entity: Entity, parent: Entity | nul
/** Every list a `Cache` keeps, for the paths that cannot ask which one applies. */
const CACHE_LISTS = [
'children', 'fills', 'shadows', 'strokes', 'effects',
- 'textRanges', 'clipPaths', 'mattes', 'keyframeTracks', 'keyframes', 'animations',
+ 'textRanges', 'clipPaths', 'masks', 'keyframeTracks', 'keyframes', 'animations',
] as const;
/**
diff --git a/packages/runtime/src/media/mask.ts b/packages/runtime/src/media/mask.ts
index d1601992..1c4fc9bc 100644
--- a/packages/runtime/src/media/mask.ts
+++ b/packages/runtime/src/media/mask.ts
@@ -8,7 +8,7 @@ import { getAssetFile } from '../actions/assets';
import type { AssetStat, MaskAsset } from '@diffusionstudio/assets';
-/** White where the object is: a matte is read by its alpha. */
+/** White where the object is: a mask is read by its alpha. */
const FOREGROUND = '#ffffff';
/** A picture's shortest side, for whatever asks for one: enough that its edge is not the blur of a small bitmap. */
@@ -25,7 +25,7 @@ export type MaskOutline = { path: Path2D; width: number; height: number; smoothi
* megabytes a minute at most — and a frame's field is decoded from its runs
* when it is asked for, which costs microseconds: nothing is decoded ahead,
* and there is no cache to keep warm. Its edge is traced into an outline at
- * the matte's smoothing (see `traceMask`) when a renderer asks for it, which
+ * the mask's smoothing (see `traceMask`) when a renderer asks for it, which
* it fills at the size the mask lands at; for whatever asks for a picture
* instead, the outline is filled on a canvas the shape of the footage.
*/
diff --git a/packages/runtime/src/systems/playback.ts b/packages/runtime/src/systems/playback.ts
index 252b6197..e25f2ea1 100644
--- a/packages/runtime/src/systems/playback.ts
+++ b/packages/runtime/src/systems/playback.ts
@@ -12,7 +12,7 @@ import { Not, Or } from 'koota';
import { store } from '../world/store';
import { PaintType } from '../constants';
import {
- ChildOf, Hidden, Culled, Dragging, AssetId, Cache, Matte,
+ ChildOf, Hidden, Culled, Dragging, AssetId, Cache, Mask,
Geometry, Group, AdjustmentLayer, Paint, Audio, Caption, Muted, Soloed,
Sequential, Transition, Playback, Workarea,
AudioPlayback, Computed,
@@ -222,18 +222,18 @@ function forwardImageDecoder(world: World, _scene: Entity, _entity: Entity, fill
}
/**
- * Seeks the frame sequences of the mattes under the entity's effects: a
- * matte's frame `i` belongs to source frame `offset + i` of the clip, so the
+ * Seeks the frame sequences of the masks under the entity's effects: a
+ * mask's frame `i` belongs to source frame `offset + i` of the clip, so the
* seek is the clip's own source frame less the offset, at the rate the
* sequence was written at (the composition's, authored as its frameRate).
*/
-function forwardMatteDecoders(world: World, scene: Entity, entity: Entity): void {
+function forwardMaskDecoders(world: World, scene: Entity, entity: Entity): void {
const cache = store(world, Cache);
const effects = cache.effects[entity.id()];
if (!effects?.length) return;
const computed = store(world, Computed);
- const matteStore = store(world, Matte);
+ const maskStore = store(world, Mask);
const eid = entity.id();
const fps = world.get(FrameRate)?.value ?? 30;
@@ -250,12 +250,12 @@ function forwardMatteDecoders(world: World, scene: Entity, entity: Entity): void
for (const effect of effects) {
if (effect.has(Hidden)) continue;
- for (const matte of cache.mattes[effect.id()] ?? []) {
- if (matte.has(Hidden) || !matte.has(AssetId)) continue;
+ for (const mask of cache.masks[effect.id()] ?? []) {
+ if (mask.has(Hidden) || !mask.has(AssetId)) continue;
- const decoder = resolveVideoDecoder(world, matte);
+ const decoder = resolveVideoDecoder(world, mask);
if (!decoder) continue;
- const frame = Math.max(0, sourceFrame - (matteStore.offset[matte.id()] ?? 0));
+ const frame = Math.max(0, sourceFrame - (maskStore.offset[mask.id()] ?? 0));
// Seek first: the editor keeps no promise list, and an optional call
// skips its arguments along with itself.
const seek = decoder.seekTo(frame, fps);
@@ -314,7 +314,7 @@ function forwardDecoders(world: World, scene: Entity, entity: Entity): void {
}
if (visualsEnabled && entity.has(Geometry)) {
- forwardMatteDecoders(world, scene, entity);
+ forwardMaskDecoders(world, scene, entity);
}
}
diff --git a/packages/runtime/src/systems/render.ts b/packages/runtime/src/systems/render.ts
index 48428d3c..f25ca488 100644
--- a/packages/runtime/src/systems/render.ts
+++ b/packages/runtime/src/systems/render.ts
@@ -19,7 +19,7 @@ import {
import {
ChildOf, Hidden, Culled, Interactive, IsClipPath, AssetId,
ClipsContent, Geometry, Group, Paint, Color, Caption, ScaleMode, Shader,
- BlendMode, Effect, Matte, Transition, MixedCornerRadius,
+ BlendMode, Effect, Mask, Transition, MixedCornerRadius,
LocalTransform, WorldTransform, Computed, Cache,
Host,
Mode, FrameRate, Camera, Background, RenderSurface,
@@ -896,10 +896,10 @@ function renderContent(world: World, entity: Entity, effects: string | null): vo
// ── Effect passes ────────────────────────────────────────────
-/** One step of a node's filter pipeline: a run of plain filters, or one effect limited by its mattes. */
+/** One step of a node's filter pipeline: a run of plain filters, or one effect limited by its masks. */
type EffectPass =
| { kind: 'filter'; filter: string }
- | { kind: 'masked'; filter: string | null; mattes: Entity[]; opacity: boolean };
+ | { kind: 'masked'; filter: string | null; masks: Entity[]; opacity: boolean };
/**
* The node's effects as passes, or null when none is masked and one CSS
@@ -910,7 +910,7 @@ type EffectPass =
function effectPasses(world: World, entity: Entity): EffectPass[] | null {
const effects = store(world, Cache).effects[entity.id()];
if (!effects?.length) return null;
- if (!effects.some((effect) => !effect.has(Hidden) && activeMattes(world, effect).length > 0)) return null;
+ if (!effects.some((effect) => !effect.has(Hidden) && activeMasks(world, effect).length > 0)) return null;
const passes: EffectPass[] = [];
let run: string[] = [];
@@ -926,13 +926,13 @@ function effectPasses(world: World, entity: Entity): EffectPass[] | null {
for (const effect of effects) {
if (effect.has(Hidden)) continue;
const filter = effectFilter(world, effect);
- const mattes = activeMattes(world, effect);
- if (mattes.length === 0) {
+ const masks = activeMasks(world, effect);
+ if (masks.length === 0) {
if (filter) run.push(filter);
continue;
}
flush();
- passes.push({ kind: 'masked', filter, mattes, opacity: types[effect.id()] === EffectType.OPACITY });
+ passes.push({ kind: 'masked', filter, masks, opacity: types[effect.id()] === EffectType.OPACITY });
}
flush();
return passes;
@@ -940,15 +940,15 @@ function effectPasses(world: World, entity: Entity): EffectPass[] | null {
const NO_MATTES: Entity[] = [];
-/** The effect's mattes that have a picture and are switched on. */
-function activeMattes(world: World, effect: Entity): Entity[] {
- const all = store(world, Cache).mattes[effect.id()];
+/** The effect's masks that have a picture and are switched on. */
+function activeMasks(world: World, effect: Entity): Entity[] {
+ const all = store(world, Cache).masks[effect.id()];
if (!all?.length) return NO_MATTES;
let active: Entity[] | null = null;
- for (const matte of all) {
- if (matte.has(Hidden) || !matte.has(AssetId)) continue;
- (active ??= []).push(matte);
+ for (const mask of all) {
+ if (mask.has(Hidden) || !mask.has(AssetId)) continue;
+ (active ??= []).push(mask);
}
return active ?? NO_MATTES;
}
@@ -1005,7 +1005,7 @@ const IDENTITY = new DOMMatrix();
* Draws the node through layers: its content unfiltered onto one, then
* each effect pass from one layer to the next (a filter run is a filtered
* copy; a masked effect combines the copy with the unfiltered picture by
- * its mattes' coverage), and the layer lands on the surface under the
+ * its masks' coverage), and the layer lands on the surface under the
* node's opacity and blend mode, which the caller has already set.
*/
function renderLayered(world: World, entity: Entity, passes: EffectPass[]): void {
@@ -1040,9 +1040,9 @@ function renderLayered(world: World, entity: Entity, passes: EffectPass[]): void
}
/**
- * One effect limited by its mattes: `front` holds the node so far, and the
- * outcome lands in `back`. The mattes' coverage K is the node's box less
- * what each matte takes away, weighted by the matte's opacity. A filter
+ * One effect limited by its masks: `front` holds the node so far, and the
+ * outcome lands in `back`. The masks' coverage K is the node's box less
+ * what each mask takes away, weighted by the mask's opacity. A filter
* shows through where K covers — front·(1−K) + filtered·K. The opacity
* effect keeps only what K covers — filtered·K — so what is outside its
* mask goes transparent, which is what a mask on Opacity means in Premiere.
@@ -1058,9 +1058,9 @@ function applyMaskedEffect(world: World, entity: Entity, pass: Extract<EffectPas
drawOnto(coverage.ctx, () => drawRectPath(world, entity));
coverage.ctx.fillStyle = '#000000';
coverage.ctx.fill();
- for (const matte of pass.mattes) {
- const strength = Math.min(1, Math.max(0, opacities[matte.id()] ?? 1));
- if (strength <= EPSILON || !drawMatteRemoval(world, entity, matte, scratch, local)) continue;
+ for (const mask of pass.masks) {
+ const strength = Math.min(1, Math.max(0, opacities[mask.id()] ?? 1));
+ if (strength <= EPSILON || !drawMaskRemoval(world, entity, mask, scratch, local)) continue;
blit(coverage, scratch.canvas, 'destination-out', 'none', strength);
}
@@ -1078,29 +1078,29 @@ function applyMaskedEffect(world: World, entity: Entity, pass: Extract<EffectPas
}
/**
- * Draws onto `layer` what `matte` takes away from the node: the node's box
- * less the matte's picture, or the picture itself when the matte is
+ * Draws onto `layer` what `mask` takes away from the node: the node's box
+ * less the mask's picture, or the picture itself when the mask is
* inverted, fitted into the box the way the node fits its footage so it lands
- * on the frame it was made from, and softened by the matte's blur. A mask
+ * on the frame it was made from, and softened by the mask's blur. A mask
* file's picture is its outline, filled at the size it lands at so its edge
- * stays sharp at any scale, smoothed as much as the matte asks. False, and nothing drawn, while the picture's frame is not decoded yet.
+ * stays sharp at any scale, smoothed as much as the mask asks. False, and nothing drawn, while the picture's frame is not decoded yet.
*/
-function drawMatteRemoval(world: World, entity: Entity, matte: Entity, layer: Layer, local: DOMMatrix): boolean {
+function drawMaskRemoval(world: World, entity: Entity, mask: Entity, layer: Layer, local: DOMMatrix): boolean {
const computed = store(world, Computed);
const eid = entity.id();
- const mid = matte.id();
+ const mid = mask.id();
const w = computed.width[eid]!;
const h = computed.height[eid]!;
- const decoder = resolveVideoDecoder(world, matte);
- const smoothing = store(world, Matte).smoothing[mid] ?? DEFAULT_MASK_SMOOTHING;
+ const decoder = resolveVideoDecoder(world, mask);
+ const smoothing = store(world, Mask).smoothing[mid] ?? DEFAULT_MASK_SMOOTHING;
const outline = decoder instanceof MaskDecoder ? decoder.getOutline(smoothing) : null;
const frame = outline ? null : decoder?.toBitmap();
const picture = outline ?? frame;
if (!picture) return false;
const feather = computed.blur[mid] ?? 0;
- const inverted = store(world, Matte).inverted[mid] ?? false;
+ const inverted = store(world, Mask).inverted[mid] ?? false;
const source = findGeometryAssetSource(world, entity);
const mode = (source && store(world, ScaleMode).value[source.id()]) ?? ScaleModeType.COVER;
const [dx, dy, sw, sh] = getScaledImageProps(mode, picture.width, picture.height, w, h);
diff --git a/packages/runtime/src/traits/derived.ts b/packages/runtime/src/traits/derived.ts
index 9093ee76..0ba136d0 100644
--- a/packages/runtime/src/traits/derived.ts
+++ b/packages/runtime/src/traits/derived.ts
@@ -56,7 +56,7 @@ export const Cache = trait({
effects: () => [] as Entity[],
textRanges: () => [] as Entity[],
clipPaths: () => [] as Entity[],
- mattes: () => [] as Entity[],
+ masks: () => [] as Entity[],
keyframeTracks: () => [] as Entity[],
keyframes: () => [] as Entity[],
animations: () => [] as Entity[],
diff --git a/packages/runtime/src/traits/style.ts b/packages/runtime/src/traits/style.ts
index f9975f77..63fc1b64 100644
--- a/packages/runtime/src/traits/style.ts
+++ b/packages/runtime/src/traits/style.ts
@@ -38,8 +38,8 @@ export const Effect = trait({
value: 0,
});
-// A `<mask>`: a matte limiting the effect holding it, ChildOf the effect.
-export const Matte = trait({
+// A `<mask>`: limits the effect holding it to where its picture is, ChildOf the effect.
+export const Mask = trait({
offset: 0,
inverted: false,
// How much a mask file's edge is smoothed, 0 to 1 (see `traceMask`).
diff --git a/packages/runtime/src/world/serialize.ts b/packages/runtime/src/world/serialize.ts
index 185fa4b9..7900a973 100644
--- a/packages/runtime/src/world/serialize.ts
+++ b/packages/runtime/src/world/serialize.ts
@@ -9,7 +9,7 @@ import {
Caption,
Position, Offset, Rotation, Scale, UniformScale, Anchor, Skew, Size, Flip,
Constraint, KeepAspectRatio,
- Opacity, BlendMode, Color, CornerRadius, MixedCornerRadius, Blur, ScaleMode, Effect, Matte,
+ Opacity, BlendMode, Color, CornerRadius, MixedCornerRadius, Blur, ScaleMode, Effect, Mask,
ColorStop, StrokeStyle, Shader,
Chars, TextStyle,
Delay, Trim, PlaybackRate, SourceFrameRate,
@@ -41,7 +41,7 @@ export interface EntityRecord {
type?: number;
value?: number;
};
- Matte?: {
+ Mask?: {
offset?: number;
inverted?: boolean;
smoothing?: number;
@@ -204,9 +204,9 @@ export function serializeEntity(entity: Entity): EntityRecord {
const effect = entity.get(Effect)!;
record.Effect = { type: effect.type, value: effect.value };
}
- if (entity.has(Matte)) {
- const matte = entity.get(Matte)!;
- record.Matte = { offset: matte.offset, inverted: matte.inverted, smoothing: matte.smoothing };
+ if (entity.has(Mask)) {
+ const mask = entity.get(Mask)!;
+ record.Mask = { offset: mask.offset, inverted: mask.inverted, smoothing: mask.smoothing };
}
if (entity.has(Shadow)) {
record.Shadow = {};
@@ -450,9 +450,9 @@ export function deserializeEntity(entity: Entity, e: Partial<EntityRecord>): voi
entity.add(Effect);
entity.set(Effect, defined(e.Effect));
}
- if (e.Matte !== undefined) {
- entity.add(Matte);
- entity.set(Matte, defined(e.Matte));
+ if (e.Mask !== undefined) {
+ entity.add(Mask);
+ entity.set(Mask, defined(e.Mask));
}
if (e.Shadow !== undefined) {
entity.add(Shadow);