The VS Code of video editing, built for agents.
TypeScript
Refactor rendering and entity management for improved paint and opacity handling
konstantin-paulus799dd5c8c284
diff --git a/packages/reconciler/src/document.ts b/packages/reconciler/src/document.tsindex f741723b..a4f256be 100644--- a/packages/reconciler/src/document.ts+++ b/packages/reconciler/src/document.ts@@ -15,6 +15,7 @@ import {createEntity,DEFAULT_BACKGROUND,Color,+ ColorStop,End,FontStyle,FrameRate,@@ -24,11 +25,13 @@ import {getEntityTree,getParentEntity,getParentNode,+ isPaintEntity,isText,ItemIndex,Muted,Name,Offset,+ Opacity,Paint,PaintType,parseColor,@@ -189,6 +192,12 @@ const TIME_TRAITS = {sourceOut: SourceOut,} as const;+const PAINT_TYPES: Record<string, PaintType> = {+ solidPaint: PaintType.SOLID,+ linearGradientPaint: PaintType.LINEAR_GRADIENT,+ radialGradientPaint: PaintType.RADIAL_GRADIENT,+};+const SCALE_MODES: Record<string, ScaleModeType> = {cover: ScaleModeType.COVER,contain: ScaleModeType.FIT,@@ -313,6 +322,17 @@ export class RuntimeDocument implements ProjectDocument<HostNode> {resizeEntity(this.world, entity, { width: 1920, height: 1080 });break;}+ case 'image': {+ entity = createEntity(this.world);+ entity.add(Geometry);+ entity.set(Geometry, { value: GeometryType.RECT });+ entity.add(Position);+ entity.set(Position, { x: 0, y: 0 });+ entity.add(Paint);+ entity.set(Paint, { value: PaintType.IMAGE });+ resizeEntity(this.world, entity, { width: 1920, height: 1080 });+ break;+ }case 'audio': {entity = createEntity(this.world);entity.add(Geometry);@@ -325,9 +345,24 @@ export class RuntimeDocument implements ProjectDocument<HostNode> {resizeEntity(this.world, entity, { width: 500, height: 150 });break;}+ case 'solidPaint':+ case 'linearGradientPaint':+ case 'radialGradientPaint': {+ entity = createEntity(this.world);+ entity.add(Paint);+ entity.set(Paint, { value: PAINT_TYPES[name]! });+ if (name === 'solidPaint') entity.add(Color);+ break;+ }+ case 'colorStop': {+ // Position only; `color`/`opacity` add Color/Opacity like anywhere else.+ entity = createEntity(this.world);+ entity.add(ColorStop);+ break;+ }default:throw new Error(- `<${tag}> is not supported yet (only <stage>, <scene>, <group>, <sequence>, <rect>, <text>, <video> and <audio>).`,+ `<${tag}> is not supported yet (only <stage>, <scene>, <group>, <sequence>, <rect>, <text>, <video>, <image>, <audio>, <solidPaint>, <linearGradientPaint>, <radialGradientPaint> and <colorStop>).`,);}@@ -513,6 +548,23 @@ export class RuntimeDocument implements ProjectDocument<HostNode> {entity.set(Color, { value: color });return;}+ case 'opacity': {+ const opacity = toNumber(value);+ if (opacity === undefined) {+ entity.remove(Opacity);+ return;+ }++ entity.add(Opacity);+ entity.set(Opacity, { value: opacity });+ return;+ }+ case 'offset': {+ if (entity.has(ColorStop)) {+ entity.set(ColorStop, { offset: toNumber(value) ?? 0 });+ }+ return;+ }case 'fontSize': {const size = toNumber(value);entity.add(TextStyle);@@ -603,8 +655,8 @@ export class RuntimeDocument implements ProjectDocument<HostNode> {if (parent.entity === node.entity) return;- if (isText(parent.entity)) {- throw new Error('<text> only takes text children.');+ if (isText(parent.entity) && !isPaintEntity(node.entity)) {+ throw new Error('<text> only takes text and paint children.');}if (getParentEntity(node.entity) !== parent.entity) {diff --git a/packages/runtime/src/constants.ts b/packages/runtime/src/constants.tsindex 7a95e2d4..2df9f483 100644--- a/packages/runtime/src/constants.ts+++ b/packages/runtime/src/constants.ts@@ -10,7 +10,7 @@ export const DEFAULT_DURATION_FRAMES = 16 * 30;export const MIN_CAMERA_ZOOM = 0.01;export const MAX_CAMERA_ZOOM = 10;-export enum BlendMode {+export enum BlendModeType {SOURCE_OVER,MULTIPLY,SCREEN,@@ -29,7 +29,7 @@ export enum BlendMode {LUMINOSITY,};-export const COMPOSITE_OPERATIONS = Object.keys(BlendMode)+export const COMPOSITE_OPERATIONS = Object.keys(BlendModeType).filter(key => isNaN(Number(key))).map(key => key.toLowerCase().replace(/_/g, '-')) as GlobalCompositeOperation[];diff --git a/packages/runtime/src/media/caption/classic.ts b/packages/runtime/src/media/caption/classic.tsindex 12d5fd12..8c03ea54 100644--- a/packages/runtime/src/media/caption/classic.ts+++ b/packages/runtime/src/media/caption/classic.ts@@ -3,7 +3,7 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { CaptionAlign, CaptionType, PaintType, FontStyle, TextAlign, TextBaseline, TextCase } from '../../constants';-import { Paint, Color, Shadow, Appearance, Blur, Offset, TextStyle } from '../../traits';+import { Paint, Color, Shadow, Opacity, Blur, Offset, TextStyle } from '../../traits';import { renderText } from '../../utils/text';import { loadWebFont } from '../../fonts/utils';import { groupBy, findActiveGroup, resolveTranscript, setChars } from './utils';@@ -72,8 +72,8 @@ export class ClassicCaptionDecoder implements CaptionDecoder {shadow.add(Shadow);shadow.add(Color);shadow.set(Color, { value: 0x000000 });- shadow.add(Appearance);- shadow.set(Appearance, { opacity: 1 });+ shadow.add(Opacity);+ shadow.set(Opacity, { value: 1 });shadow.add(Blur);shadow.set(Blur, { value: 28 });shadow.add(Offset);diff --git a/packages/runtime/src/media/caption/stark.ts b/packages/runtime/src/media/caption/stark.tsindex 4714973e..452d310d 100644--- a/packages/runtime/src/media/caption/stark.ts+++ b/packages/runtime/src/media/caption/stark.ts@@ -2,8 +2,8 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { BlendMode, CaptionAlign, CaptionType, PaintType, FontStyle, TextAlign, TextBaseline, TextCase } from '../../constants';-import { Paint, Color, Appearance, TextStyle } from '../../traits';+import { BlendModeType, CaptionAlign, CaptionType, PaintType, FontStyle, TextAlign, TextBaseline, TextCase } from '../../constants';+import { Paint, Color, BlendMode, TextStyle } from '../../traits';import { renderText } from '../../utils/text';import { loadWebFont } from '../../fonts/utils';import { groupBy, findActiveGroup, resolveTranscript, setChars } from './utils';@@ -62,8 +62,8 @@ export class StarkCaptionDecoder implements CaptionDecoder {fill.set(Paint, { value: PaintType.SOLID });fill.add(Color);fill.set(Color, { value: 0xFFFFFF });- fill.add(Appearance);- fill.set(Appearance, { blendMode: BlendMode.DIFFERENCE });+ fill.add(BlendMode);+ fill.set(BlendMode, { value: BlendModeType.DIFFERENCE });appendChild(world, fill, entity);loadWebFont(world, 'Figtree');diff --git a/packages/runtime/src/systems/gradients.ts b/packages/runtime/src/systems/gradients.tsindex 54409965..d42f56ef 100644--- a/packages/runtime/src/systems/gradients.ts+++ b/packages/runtime/src/systems/gradients.ts@@ -8,7 +8,7 @@import { store } from '../world/store';import { ChildOf, ColorStop, Position, Computed } from '../traits';-import { colorToHex } from '../utils/color';+import { colorToCss } from '../utils/color';import type { Entity, World } from 'koota';@@ -21,26 +21,17 @@ function addStopsTo(world: World, fill: Entity, gradient: CanvasGradient): voidconst raw = computed.stopOffset[stop.id()]!;return {offset: raw <= 1 ? Math.max(0, raw) : raw % 1,- color: computed.stopColor[stop.id()]!,- opacity: computed.stopOpacity[stop.id()]!,+ color: computed.color[stop.id()] ?? 0,+ opacity: computed.opacity[stop.id()] ?? 1,};}).sort((a, b) => a.offset - b.offset);for (const { offset, color, opacity } of stops) {- gradient.addColorStop(offset, toGradientColor(color, opacity));+ gradient.addColorStop(offset, colorToCss(color, opacity));}}-function toGradientColor(color: number, opacity: number): string {- if (opacity >= 1) return colorToHex(color);-- const r = (color >> 16) & 0xFF;- const g = (color >> 8) & 0xFF;- const b = color & 0xFF;- return `rgba(${r},${g},${b},${Math.max(0, Math.min(1, opacity))})`;-}-/** Create a canvas linear gradient from a gradient paint sub-entity. */export function createLinearGradient(world: World,diff --git a/packages/runtime/src/systems/motion.ts b/packages/runtime/src/systems/motion.tsindex 2c798fdc..47b773b7 100644--- a/packages/runtime/src/systems/motion.ts+++ b/packages/runtime/src/systems/motion.ts@@ -9,7 +9,7 @@ import { store } from '../world/store';import {Geometry, Group, AdjustmentLayer, Hidden, Culled,Computed, Cache, Animation, KeyframeTrack, Keyframe, Chars,- UniformScale, Position, Offset, Rotation, Scale, Skew, Size, Appearance,+ UniformScale, Position, Offset, Rotation, Scale, Skew, Size, Opacity,Color, Blur, Volume, Effect, StrokeStyle, CornerRadius, MixedCornerRadius,ColorStop,} from '../traits';@@ -36,7 +36,7 @@ export function resetAnimatedValues(world: World, entity: Entity | null) {computed.rotation[eid] = store(world, Rotation).value[eid] ?? 0;computed.skewX[eid] = store(world, Skew).x[eid] ?? 0;computed.skewY[eid] = store(world, Skew).y[eid] ?? 0;- computed.opacity[eid] = store(world, Appearance).opacity[eid] ?? 1;+ computed.opacity[eid] = store(world, Opacity).value[eid] ?? 1;computed.color[eid] = store(world, Color).value[eid] ?? 0;computed.blur[eid] = store(world, Blur).value[eid] ?? 0;computed.volume[eid] = store(world, Volume).value[eid] ?? 0;@@ -47,8 +47,6 @@ export function resetAnimatedValues(world: World, entity: Entity | null) {computed.cornerRadiusBottomRight[eid] = store(world, MixedCornerRadius).bottomRight[eid] ?? 0;computed.cornerRadiusBottomLeft[eid] = store(world, MixedCornerRadius).bottomLeft[eid] ?? 0;computed.stopOffset[eid] = store(world, ColorStop).offset[eid] ?? 0;- computed.stopColor[eid] = store(world, ColorStop).color[eid] ?? 0;- computed.stopOpacity[eid] = store(world, ColorStop).opacity[eid] ?? 1;computed.chars[eid] = store(world, Chars).value[eid] ?? '';if (entity.has(UniformScale)) {@@ -297,7 +295,7 @@ export function getPropertyPaths(world: World) {},'opacity': {computed: computed.opacity,- authored: store(world, Appearance).opacity,+ authored: store(world, Opacity).value,},'color': {computed: computed.color,@@ -343,14 +341,6 @@ export function getPropertyPaths(world: World) {computed: computed.stopOffset,authored: store(world, ColorStop).offset,},- 'stop.color': {- computed: computed.stopColor,- authored: store(world, ColorStop).color,- },- 'stop.opacity': {- computed: computed.stopOpacity,- authored: store(world, ColorStop).opacity,- },'chars': {computed: computed.chars,authored: store(world, Chars).value,@@ -462,7 +452,7 @@ function sampleTrack(const startValue = keyframe.value[keyframes[i]!.id()]!;const endValue = keyframe.value[keyframes[i + 1]!.id()]!;- if (property === 'color' || property === 'stop.color') {+ if (property === 'color') {return lerpColor(startValue, endValue, progress);}diff --git a/packages/runtime/src/systems/render.ts b/packages/runtime/src/systems/render.tsindex fbdcb7f4..27f14a17 100644--- a/packages/runtime/src/systems/render.ts+++ b/packages/runtime/src/systems/render.ts@@ -19,7 +19,7 @@ import {import {ChildOf, Hidden, Culled, Generating, Interactive, IsMask,ClipsContent, Geometry, Group, Paint, Color, Caption, ScaleMode, Shader,- Appearance, Effect, StrokeStyle, AssetId, Transition, MixedCornerRadius,+ BlendMode, Effect, StrokeStyle, AssetId, Transition, MixedCornerRadius,LocalTransform, WorldTransform, Computed, Cache,HtmlHostHandle, SurfaceHostHandle,Mode, Time, FrameRate, Camera, Background, RenderSurface, Assets,@@ -204,7 +204,9 @@ function buildEffects(world: World, entity: Entity): string | null {export function renderIntrinsicFill(world: World, entity: Entity): void {if (entity.has(Color)) {const ctx = getCtx(world);- ctx.fillStyle = colorToHex(store(world, Computed).color[entity.id()] ?? 0);+ const computed = store(world, Computed);+ const eid = entity.id();+ ctx.fillStyle = colorToHex(computed.color[eid] ?? 0);ctx.fill();}@@ -273,7 +275,7 @@ export function renderFills(world: World, entity: Entity): void {const ctx = getCtx(world);const computed = store(world, Computed);const paintStore = store(world, Paint);- const appearance = store(world, Appearance);+ const blendMode = store(world, BlendMode);const eid = entity.id();const fills = store(world, Cache).fills[eid] ?? [];@@ -283,7 +285,7 @@ export function renderFills(world: World, entity: Entity): void {const fid = fill.id();const savedAlpha = ctx.globalAlpha;const savedCO = ctx.globalCompositeOperation;- const bi = appearance.blendMode[fid] ?? 0;+ const bi = blendMode.value[fid] ?? 0;if (bi !== 0) {ctx.globalCompositeOperation = COMPOSITE_OPERATIONS[bi]!;@@ -497,7 +499,7 @@ function renderStrokes(world: World, entity: Entity): void {const strokeStyle = store(world, StrokeStyle);const computed = store(world, Computed);- const appearance = store(world, Appearance);+ const blendMode = store(world, BlendMode);const paintStore = store(world, Paint);ctx.lineWidth = computed.strokeWidth[eid]!;@@ -510,7 +512,7 @@ function renderStrokes(world: World, entity: Entity): void {const sid = stroke.id();const savedAlpha = ctx.globalAlpha;const savedCO = ctx.globalCompositeOperation;- const bi = appearance.blendMode[sid] ?? 0;+ const bi = blendMode.value[sid] ?? 0;if (bi !== 0) {ctx.globalCompositeOperation = COMPOSITE_OPERATIONS[bi]!;@@ -810,9 +812,9 @@ export function renderNode(world: World, entity: Entity): void {ctx.clip();}- // Appearance+ // Opacity and blend modectx.globalAlpha *= computed.opacity[eid]!;- const bi = store(world, Appearance).blendMode[eid] ?? 0;+ const bi = store(world, BlendMode).value[eid] ?? 0;if (bi !== 0) ctx.globalCompositeOperation = COMPOSITE_OPERATIONS[bi]!;const effects = buildEffects(world, entity);diff --git a/packages/runtime/src/traits/derived.ts b/packages/runtime/src/traits/derived.tsindex 8433c9f9..7e02ba4e 100644--- a/packages/runtime/src/traits/derived.ts+++ b/packages/runtime/src/traits/derived.ts@@ -33,8 +33,6 @@ export const Computed = trait({cornerRadiusBottomRight: 0,cornerRadiusBottomLeft: 0,stopOffset: 0,- stopColor: 0,- stopOpacity: 1,width: 0,height: 0,chars: undefined as string | undefined,diff --git a/packages/runtime/src/traits/style.ts b/packages/runtime/src/traits/style.tsindex 0cd13442..882c77c6 100644--- a/packages/runtime/src/traits/style.ts+++ b/packages/runtime/src/traits/style.ts@@ -4,14 +4,16 @@import { trait } from 'koota';-import { BlendMode, EffectType, ScaleModeType, StrokeJoin, StrokeCap } from '../constants';+import { BlendModeType, EffectType, ScaleModeType, StrokeJoin, StrokeCap } from '../constants';-export const Appearance = trait({- opacity: 1,- blendMode: BlendMode.SOURCE_OVER as BlendMode,-});+// Opacity of whatever the entity is: a node, a paint, a stroke, a shadow, a+// gradient stop's color. Absent means opaque.+export const Opacity = trait({ value: 1 });++// How the entity composites over what is below it. Absent means source-over.+export const BlendMode = trait({ value: BlendModeType.SOURCE_OVER as BlendModeType });-// Solid color.+// Solid color (0xRRGGBB). Its translucency, when any, is the entity's Opacity.export const Color = trait({ value: 0 });export const CornerRadius = trait({ value: 0 });@@ -35,10 +37,12 @@ export const Effect = trait({value: 0,});-// Single gradient stop. Each stop is its own entity, ChildOf the gradient-// fill. Stop count is fixed for the lifetime of the fill: to animate between-// gradients with different stop counts use a separate fill and cross-fade.-export const ColorStop = trait({ offset: 0, color: 0, opacity: 1 });+// Single gradient stop: its position along the gradient (0-1). Its color and+// opacity are the entity's Color and Opacity. Each stop is its own entity, ChildOf the+// gradient fill. Stop count is fixed for the lifetime of the fill: to animate+// between gradients with different stop counts use a separate fill and+// cross-fade.+export const ColorStop = trait({ offset: 0 });export const StrokeStyle = trait({width: 1,diff --git a/packages/runtime/src/utils/color.ts b/packages/runtime/src/utils/color.tsindex 604d5a67..d9f43c4b 100644--- a/packages/runtime/src/utils/color.ts+++ b/packages/runtime/src/utils/color.ts@@ -106,6 +106,18 @@ export function colorToHex(color: number): string {return '#' + ((1 << 24) | (color & 0xFFFFFF)).toString(16).slice(1).toUpperCase();}+/**+ * A CSS color for `color` at `opacity`: the hex when opaque, else an rgba().+ */+export function colorToCss(color: number, opacity: number): string {+ if (opacity >= 1) return colorToHex(color);++ const r = (color >> 16) & 0xFF;+ const g = (color >> 8) & 0xFF;+ const b = color & 0xFF;+ return `rgba(${r},${g},${b},${clamp(opacity, 0, 1)})`;+}+/*** Packs RGB channel values (0-255) into a numeric hex color (0xRRGGBB).*/diff --git a/packages/runtime/src/utils/text.ts b/packages/runtime/src/utils/text.tsindex cdea2256..1f572fee 100644--- a/packages/runtime/src/utils/text.ts+++ b/packages/runtime/src/utils/text.ts@@ -10,7 +10,7 @@ import {TextAlign, TextBaseline, TextCase,} from '../constants';import {- Size, Hidden, Paint, Color, Blur, Offset, Appearance, StrokeStyle,+ Size, Hidden, Paint, Color, Blur, Offset, Opacity, BlendMode, StrokeStyle,Chars, TextStyle, TextRange, TextCache, Cache, Computed, Camera,RenderSurface, Root,} from '../traits';@@ -284,7 +284,8 @@ function renderTokens(ctx: Ctx, world: World, entity: Entity): void {const offsetStore = store(world, Offset);const blurStore = store(world, Blur);const colorStore = store(world, Color);- const appearance = store(world, Appearance);+ const opacityStore = store(world, Opacity);+ const blendStore = store(world, BlendMode);const paintStore = store(world, Paint);const savedAlpha = ctx.globalAlpha;@@ -322,7 +323,7 @@ function renderTokens(ctx: Ctx, world: World, entity: Entity): void {ctx.shadowBlur = (blurStore.value[sid] ?? 0) * shadowScale;ctx.shadowColor = colorToHex(colorStore.value[sid] ?? 0x000000);ctx.fillStyle = colorToHex(colorStore.value[sid] ?? 0x000000);- ctx.globalAlpha = savedAlpha * (appearance.opacity[sid] ?? 1);+ ctx.globalAlpha = savedAlpha * (opacityStore.value[sid] ?? 1);if (strokes.length) {ctx.strokeText(word.chars, word.x, word.y);@@ -362,11 +363,11 @@ function renderTokens(ctx: Ctx, world: World, entity: Entity): void {const sid = stroke.id();const savedCO = ctx.globalCompositeOperation;- const blendMode = appearance.blendMode[sid] ?? 0;+ const blendMode = blendStore.value[sid] ?? 0;if (blendMode !== 0) {ctx.globalCompositeOperation = COMPOSITE_OPERATIONS[blendMode]!;}- ctx.globalAlpha = savedAlpha * (appearance.opacity[sid] ?? 1);+ ctx.globalAlpha = savedAlpha * (opacityStore.value[sid] ?? 1);const paintType = paintStore.value[sid];if (paintType === PaintType.LINEAR_GRADIENT) {@@ -413,11 +414,11 @@ function renderTokens(ctx: Ctx, world: World, entity: Entity): void {const fid = fill.id();const savedCO = ctx.globalCompositeOperation;- const blendMode = appearance.blendMode[fid] ?? 0;+ const blendMode = blendStore.value[fid] ?? 0;if (blendMode !== 0) {ctx.globalCompositeOperation = COMPOSITE_OPERATIONS[blendMode]!;}- ctx.globalAlpha = savedAlpha * (appearance.opacity[fid] ?? 1);+ ctx.globalAlpha = savedAlpha * (opacityStore.value[fid] ?? 1);const paintType = paintStore.value[fid];if (paintType === PaintType.LINEAR_GRADIENT) {diff --git a/packages/runtime/src/world/observers.ts b/packages/runtime/src/world/observers.tsindex b237a96f..33c8993c 100644--- a/packages/runtime/src/world/observers.ts+++ b/packages/runtime/src/world/observers.ts@@ -21,7 +21,7 @@ import {ChildOf, Culled, Sequential, Group, Scene, Audio, Paint, AssetId,Start, End, SourceIn, SourceOut, PlaybackRate, Keyframe, ItemIndex,Position, Offset, Rotation, Scale, UniformScale, Skew, Anchor, Flip,- Appearance, Color, Blur, Volume, Effect, CornerRadius, MixedCornerRadius,+ Opacity, Color, Blur, Volume, Effect, CornerRadius, MixedCornerRadius,ColorStop, StrokeStyle, Size, Computed, Active, Stage,ImageDecoderHandle, VideoDecoderHandle, SequenceDecoderHandle,AudioDecoderHandle, CaptionDecoderHandle,@@ -207,8 +207,8 @@ export function observeWorld(world: World): () => void {computed.skewY[entity.id()] = y;});- mirror(Appearance, (entity) => {- store(world, Computed).opacity[entity.id()] = entity.get(Appearance)!.opacity;+ mirror(Opacity, (entity) => {+ store(world, Computed).opacity[entity.id()] = entity.get(Opacity)!.value;});mirror(Color, (entity) => {@@ -241,11 +241,7 @@ export function observeWorld(world: World): () => void {});mirror(ColorStop, (entity) => {- const computed = store(world, Computed);- const stop = entity.get(ColorStop)!;- computed.stopOffset[entity.id()] = stop.offset;- computed.stopColor[entity.id()] = stop.color;- computed.stopOpacity[entity.id()] = stop.opacity;+ store(world, Computed).stopOffset[entity.id()] = entity.get(ColorStop)!.offset;});mirror(StrokeStyle, (entity) => {diff --git a/packages/runtime/src/world/serialize.ts b/packages/runtime/src/world/serialize.tsindex 9cf0a483..1c03c693 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,- Appearance, Color, CornerRadius, MixedCornerRadius, Blur, ScaleMode, Effect,+ Opacity, BlendMode, Color, CornerRadius, MixedCornerRadius, Blur, ScaleMode, Effect,ColorStop, StrokeStyle, Shader,Chars, TextStyle,Start, End, SourceIn, SourceOut, PlaybackRate,@@ -93,10 +93,8 @@ export interface EntityRecord {x?: -1 | 1;y?: -1 | 1;};- Appearance?: {- opacity?: number;- blendMode?: number;- };+ Opacity?: number;+ BlendMode?: number;CornerRadius?: number;MixedCornerRadius?: {topLeft: number;@@ -116,8 +114,6 @@ export interface EntityRecord {Muted?: {};ColorStop?: {offset?: number;- color?: number;- opacity?: number;};StrokeStyle?: {width?: number;@@ -271,9 +267,11 @@ export function serializeEntity(entity: Entity): EntityRecord {const flip = entity.get(Flip)!;record.Flip = { x: flip.x, y: flip.y };}- if (entity.has(Appearance)) {- const appearance = entity.get(Appearance)!;- record.Appearance = { opacity: appearance.opacity, blendMode: appearance.blendMode };+ if (entity.has(Opacity)) {+ record.Opacity = entity.get(Opacity)!.value;+ }+ if (entity.has(BlendMode)) {+ record.BlendMode = entity.get(BlendMode)!.value;}if (entity.has(CornerRadius)) {record.CornerRadius = entity.get(CornerRadius)!.value;@@ -310,8 +308,7 @@ export function serializeEntity(entity: Entity): EntityRecord {record.Muted = {};}if (entity.has(ColorStop)) {- const stop = entity.get(ColorStop)!;- record.ColorStop = { offset: stop.offset, color: stop.color, opacity: stop.opacity };+ record.ColorStop = { offset: entity.get(ColorStop)!.offset };}if (entity.has(StrokeStyle)) {const stroke = entity.get(StrokeStyle)!;@@ -516,9 +513,13 @@ export function deserializeEntity(entity: Entity, e: Partial<EntityRecord>): voientity.add(Flip);entity.set(Flip, defined(e.Flip));}- if (e.Appearance !== undefined) {- entity.add(Appearance);- entity.set(Appearance, defined(e.Appearance));+ if (e.Opacity !== undefined) {+ entity.add(Opacity);+ entity.set(Opacity, { value: e.Opacity });+ }+ if (e.BlendMode !== undefined) {+ entity.add(BlendMode);+ entity.set(BlendMode, { value: e.BlendMode });}if (e.CornerRadius !== undefined) {entity.add(CornerRadius);