The VS Code of video editing, built for agents.
TypeScript
Add stroke dash properties and related SVG icons for enhanced stroke customization
konstantin-paulusd5190170d6c2
diff --git a/apps/web/src/assets/icons/preferences-adjust-vertical.svg b/apps/web/src/assets/icons/preferences-adjust-vertical.svgnew file mode 100644index 00000000..dbc2e6f5--- /dev/null+++ b/apps/web/src/assets/icons/preferences-adjust-vertical.svg@@ -0,0 +1,5 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M15.5 7V8.5M15.5 12.5V18M9.5 7V12.5M9.5 16.5V18" stroke="currentColor" stroke-linecap="round"/>+<circle cx="15.5" cy="10.5" r="2" stroke="currentColor"/>+<circle cx="9.5" cy="14.5" r="2" stroke="currentColor"/>+</svg>diff --git a/apps/web/src/assets/icons/stroke.dash-offset.svg b/apps/web/src/assets/icons/stroke.dash-offset.svgnew file mode 100644index 00000000..ff85c450--- /dev/null+++ b/apps/web/src/assets/icons/stroke.dash-offset.svg@@ -0,0 +1,4 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M8.5 9.5H16.5M14.5 7.5L16.5 9.5L14.5 11.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+<path opacity="0.5" d="M5.5 15.5H7.5M10.5 15.5H14.5M17.5 15.5H19.5" stroke="currentColor" stroke-linecap="round"/>+</svg>diff --git a/apps/web/src/assets/icons/stroke.dash.svg b/apps/web/src/assets/icons/stroke.dash.svgnew file mode 100644index 00000000..55271e87--- /dev/null+++ b/apps/web/src/assets/icons/stroke.dash.svg@@ -0,0 +1,4 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M10.5 12.5H14.5" stroke="currentColor" stroke-linecap="round"/>+<path opacity="0.5" d="M5.5 12.5H7.5M17.5 12.5H19.5" stroke="currentColor" stroke-linecap="round"/>+</svg>diff --git a/apps/web/src/assets/icons/stroke.dashed.svg b/apps/web/src/assets/icons/stroke.dashed.svgnew file mode 100644index 00000000..3eb9d9f1--- /dev/null+++ b/apps/web/src/assets/icons/stroke.dashed.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M6 12.5H9M11 12.5H14M16 12.5H19" stroke="currentColor"/>+</svg>diff --git a/apps/web/src/assets/icons/stroke.gap.svg b/apps/web/src/assets/icons/stroke.gap.svgnew file mode 100644index 00000000..e770a2e0--- /dev/null+++ b/apps/web/src/assets/icons/stroke.gap.svg@@ -0,0 +1,4 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M10.5 9.5V15.5M14.5 9.5V15.5" stroke="currentColor" stroke-linecap="round"/>+<path opacity="0.5" d="M5.5 12.5H8.5M16.5 12.5H19.5" stroke="currentColor" stroke-linecap="round"/>+</svg>diff --git a/apps/web/src/assets/icons/stroke.solid.svg b/apps/web/src/assets/icons/stroke.solid.svgnew file mode 100644index 00000000..b3d985b7--- /dev/null+++ b/apps/web/src/assets/icons/stroke.solid.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M6 12.5H19" stroke="currentColor"/>+</svg>diff --git a/apps/web/src/components/sidebar-right/inspector/stroke-inspector.tsx b/apps/web/src/components/sidebar-right/inspector/stroke-inspector.tsxindex f7c713d9..30f1354e 100644--- a/apps/web/src/components/sidebar-right/inspector/stroke-inspector.tsx+++ b/apps/web/src/components/sidebar-right/inspector/stroke-inspector.tsx@@ -2,10 +2,17 @@* 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 { Show, createMemo, createSignal } from "solid-js";+import { For, Show, createMemo, createSignal } from "solid-js";import { Button } from "@/components/ui/button";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { Icon } from "@/components/ui/icon";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuPortal,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";import {FloatingInspector,FloatingInspectorContent,@@ -18,15 +25,15 @@ import { FillItem } from "@/components/ui/fill-item";import { ControlledTextField } from "@/components/ui/text-field";import { SegmentedIconTabs } from "@/components/ui/segmented-icon-tabs";import { Keyframe } from "@/components/ui/keyframe";-import { useTrait, useWorld } from "@diffusionstudio/koota-solid";-import { Cache, Computed, StrokeJoin, StrokeStyle } from "@diffusionstudio/runtime";+import { useHas, useTrait, useWorld } from "@diffusionstudio/koota-solid";+import { Cache, Computed, StrokeDash, StrokeJoin, StrokeStyle } from "@diffusionstudio/runtime";import { useDerived, useEditor } from "@/engine/hooks";-import { syncKeyframe } from "@/engine/keyframes";+import { removeKeyframeTrack, syncKeyframe } from "@/engine/keyframes";import { FillPicker, type FillTab } from "./fill-picker";import type { Accessor } from "solid-js";-import type { StrokeJoin as StrokeJoinName } from "@diffusionstudio/jsx";+import type { AnimatableProperty, StrokeJoin as StrokeJoinName } from "@diffusionstudio/jsx";import type { Entity } from "koota";const JOIN_SEGMENTS: { value: StrokeJoinName; icon: string; label: string }[] = [@@ -35,6 +42,19 @@ const JOIN_SEGMENTS: { value: StrokeJoinName; icon: string; label: string }[] ={ value: "round", icon: "line-join-round", label: "Round" },];+type LineStyle = "solid" | "dashed";++const STYLE_OPTIONS: { value: LineStyle; icon: string; label: string }[] = [+ { value: "solid", icon: "stroke.solid", label: "Solid" },+ { value: "dashed", icon: "stroke.dashed", label: "Dashed" },+];++/** The props a dashed line adds, all cleared when it goes back to solid. */+const DASH_PROPS: AnimatableProperty[] = ["dash", "dashGap", "dashOffset"];++/** The dash a solid line takes when it is switched to dashed, its gap the same. */+const DASHED_DASH = 10;+const JOIN_NAMES: Record<StrokeJoin, StrokeJoinName> = {[StrokeJoin.MITER]: "miter",[StrokeJoin.BEVEL]: "bevel",@@ -44,9 +64,11 @@ const JOIN_NAMES: Record<StrokeJoin, StrokeJoinName> = {/** A line is drawn with a color or a gradient, never a picture. */const STROKE_TABS: FillTab[] = ["solid", "gradient"];-/** `<stroke>`'s defaults; a control left at one of these unsets its prop. */+/** `<stroke>`'s defaults; a control left at one of these unsets its prop, but the dash ones. */const DEFAULT_WIDTH = 1;const DEFAULT_MITER_LIMIT = 10;+const DEFAULT_DASH = 0;+const DEFAULT_DASH_OFFSET = 0;// Stable identity, so a stroke without paint children does not resample every tick.const NO_PAINTS: Entity[] = [];@@ -69,12 +91,12 @@ type StrokeInspectorProps = {};/**- * One `<stroke>`: its paint and its line style (`width`/`join`/`miterLimit`).- * The paint is the stroke's own `color` or a gradient paint child, picked in- * the fill picker without its asset tab; a gradient is placed in the box of- * the stroke's parent, so that is where its handles go. `cap` has no control- * yet: it only shows on open paths (text glyphs, open `<path>` subpaths) and- * there are no icons for it.+ * One `<stroke>`: its paint and its line style (`width`/`join`/`miterLimit`,+ * and when the header's settings menu has it dashed `dash`/`dashGap`/+ * `dashOffset`). The paint is the stroke's own `color` or a+ * gradient paint child, picked in the fill picker without its asset tab; a+ * gradient is placed in the box of the stroke's parent, so that is where its+ * handles go. `cap` has no control yet: there are no icons for it.*/export function StrokeInspector(props: StrokeInspectorProps) {const world = useWorld();@@ -92,6 +114,13 @@ export function StrokeInspector(props: StrokeInspectorProps) {const join = createMemo(() => JOIN_NAMES[style()?.join ?? StrokeJoin.MITER]);const miterLimit = () => style()?.miterLimit ?? DEFAULT_MITER_LIMIT;+ const dash = useDerived(() => props.stroke.get(Computed)?.dash ?? DEFAULT_DASH);+ const dashGap = useDerived(() => props.stroke.get(Computed)?.dashGap ?? DEFAULT_DASH);+ const dashOffset = useDerived(() => props.stroke.get(Computed)?.dashOffset ?? DEFAULT_DASH_OFFSET);++ const isDashed = useHas(() => props.stroke, StrokeDash);+ const lineStyle = (): LineStyle => (isDashed() ? "dashed" : "solid");+const editWidth = (value: number) => {// Unlike a node's width this is the line width, not `resizeEntity`, so// there is no track of its own to mint and the sync belongs after.@@ -111,6 +140,36 @@ export function StrokeInspector(props: StrokeInspectorProps) {);};+ // The dash fields write even their defaults: unsetting the last of them+ // would make the line solid, and only the style menu does that.+ const editDash = (value: number) => {+ editor.editProperty(props.stroke, "dash", value);+ syncKeyframe(world, editor, props.stroke, "dash", value);+ };++ const editDashGap = (value: number) => {+ editor.editProperty(props.stroke, "dashGap", value);+ syncKeyframe(world, editor, props.stroke, "dashGap", value);+ };++ const editDashOffset = (value: number) => {+ editor.editProperty(props.stroke, "dashOffset", value);+ syncKeyframe(world, editor, props.stroke, "dashOffset", value);+ };++ // Solid clears every dash prop and its track.+ const editLineStyle = (value: LineStyle) => {+ if (value === lineStyle()) return;+ if (value === "solid") {+ for (const property of DASH_PROPS) {+ removeKeyframeTrack(world, editor, props.stroke, property);+ editor.editProperty(props.stroke, property, false);+ }+ return;+ }+ editor.editProperty(props.stroke, "dash", DASHED_DASH);+ };+const handleClose = () => {setPickingPaint(false);props.onClose();@@ -121,18 +180,67 @@ export function StrokeInspector(props: StrokeInspectorProps) {<FloatingInspector open anchorRef={props.anchorRef} width={248} ref={inspectorRef} onClose={handleClose}><FloatingInspectorHeader class="items-center justify-between"><FloatingInspectorTitle>Stroke</FloatingInspectorTitle>- <Tooltip>- <TooltipTrigger- as={Button}- size="icon"- variant="ghost"- class="text-muted-foreground"- onClick={handleClose}- >- <Icon name="close-remove" />- </TooltipTrigger>- <TooltipContent>Close</TooltipContent>- </Tooltip>+ <div class="flex items-center">+ <DropdownMenu placement="bottom-end">+ <Tooltip>+ <TooltipTrigger<typeof DropdownMenuTrigger>+ as={(triggerProps: object) => (+ <DropdownMenuTrigger<typeof Button>+ {...triggerProps}+ as={(buttonProps) => (+ <Button+ {...buttonProps}+ size="icon"+ variant="ghost"+ class="text-muted-foreground data-expanded:bg-accent data-expanded:text-foreground"+ >+ <Icon name="preferences-adjust-vertical" />+ </Button>+ )}+ />+ )}+ />+ <TooltipContent>Stroke style</TooltipContent>+ </Tooltip>+ <DropdownMenuPortal>+ <DropdownMenuContent class="w-32">+ <For each={STYLE_OPTIONS}>+ {(option) => (+ <DropdownMenuItem+ tone="neutral"+ class="gap-1 px-0 pr-2"+ onSelect={() => editLineStyle(option.value)}+ >+ <span class="w-6 h-7 shrink-0 flex items-center justify-center">+ <Show when={lineStyle() === option.value}>+ <Icon name="confirm-check" class="text-popover-foreground" />+ </Show>+ </span>+ <span class="w-7 h-7 shrink-0 flex items-center justify-center">+ <Icon name={option.icon} class="text-popover-foreground" />+ </span>+ <span class="flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap">+ {option.label}+ </span>+ </DropdownMenuItem>+ )}+ </For>+ </DropdownMenuContent>+ </DropdownMenuPortal>+ </DropdownMenu>+ <Tooltip>+ <TooltipTrigger+ as={Button}+ size="icon"+ variant="ghost"+ class="text-muted-foreground"+ onClick={handleClose}+ >+ <Icon name="close-remove" />+ </TooltipTrigger>+ <TooltipContent>Close</TooltipContent>+ </Tooltip>+ </div></FloatingInspectorHeader><FloatingInspectorSeparator /><FloatingInspectorContent class="flex flex-col gap-2 p-4">@@ -154,6 +262,49 @@ export function StrokeInspector(props: StrokeInspectorProps) {/></ControlRow>+ <Show when={lineStyle() === "dashed"}>+ <ControlRow label="Dash">+ <ControlledTextField+ icon={<Icon name="stroke.dash" />}+ value={dash()}+ onNumber={editDash}+ step={1}+ min={0}+ autoSelect+ sliderEnabled+ limitEvents+ keyframe={<Keyframe target={props.stroke} property="dash" />}+ />+ </ControlRow>++ <ControlRow label="Gap">+ <ControlledTextField+ icon={<Icon name="stroke.gap" />}+ value={dashGap()}+ onNumber={editDashGap}+ step={1}+ min={0}+ autoSelect+ sliderEnabled+ limitEvents+ keyframe={<Keyframe target={props.stroke} property="dashGap" />}+ />+ </ControlRow>++ <ControlRow label="Offset">+ <ControlledTextField+ icon={<Icon name="stroke.dash-offset" />}+ value={dashOffset()}+ onNumber={editDashOffset}+ step={1}+ autoSelect+ sliderEnabled+ limitEvents+ keyframe={<Keyframe target={props.stroke} property="dashOffset" />}+ />+ </ControlRow>+ </Show>+<ControlRow label="Join"><SegmentedIconTabsvalue={join}@@ -186,7 +337,7 @@ export function StrokeInspector(props: StrokeInspectorProps) {fill={paint()}tabs={STROKE_TABS}onClose={() => setPickingPaint(false)}- onReplace={() => {}}+ onReplace={() => { }}/></Show></>diff --git a/apps/web/src/components/sidebar-right/inspector/strokes.tsx b/apps/web/src/components/sidebar-right/inspector/strokes.tsxindex bb38e468..0ef9f709 100644--- a/apps/web/src/components/sidebar-right/inspector/strokes.tsx+++ b/apps/web/src/components/sidebar-right/inspector/strokes.tsx@@ -45,7 +45,7 @@ type StrokesSettingsProps = {* shown topmost first, so the last element in the file is the first row).* A row opens the stroke's own inspector; what it shows is the paint the* inspector edits (see `useStrokePaint`): its color, or which gradient. The line style- * (`width`/`join`/`miterLimit`) is the stroke's own and not the node's, so it+ * (`width`/`join`/`miterLimit`/`dash`/`dashGap`/`dashOffset`) is the stroke's own and not the node's, so it* lives in that inspector rather than under every row.*/export function StrokesSettings(props: StrokesSettingsProps) {diff --git a/apps/web/src/components/timeline/layers/keyframe.tsx b/apps/web/src/components/timeline/layers/keyframe.tsxindex bfff2104..b865bbea 100644--- a/apps/web/src/components/timeline/layers/keyframe.tsx+++ b/apps/web/src/components/timeline/layers/keyframe.tsx@@ -169,6 +169,9 @@ const PROPERTY_NAMES: Partial<Record<PropertyPath, string>> = {'blur': 'Blur','volume': 'Volume','stroke.width': 'Stroke Width',+ 'stroke.dash': 'Dash',+ 'stroke.dashGap': 'Dash Gap',+ 'stroke.dashOffset': 'Dash Offset','vertexRadius': 'Radius','mixedVertexRadius.topLeft': 'Radius TL','mixedVertexRadius.topRight': 'Radius TR',diff --git a/docs/reference/jsx/keyframes.md b/docs/reference/jsx/keyframes.mdindex 414647b1..abf5def2 100644--- a/docs/reference/jsx/keyframes.md+++ b/docs/reference/jsx/keyframes.md@@ -20,7 +20,7 @@ A `<keyframeTrack>` animates one prop of the element holding it over the node's| `<keyframeTrack>` | `property` (**required**) | The prop of the holding element it drives, by name. One track per prop. || `<keyframe>` | `time` (**required**), `value` (**required**), `easing` | One keyframe: source-local time in any [time format](./timing.md#time-formats), the value at that time (a number, any CSS color on a `color` track, or path data on a `d` track), and the easing into the next keyframe. |-Animatable props (`property`): `x`, `y`, `offsetX`, `offsetY`, `width`, `height`, `rotation`, `scale`, `scaleX`, `scaleY`, `opacity`, `cornerRadius`, `cornerRadiusTopLeft`, `cornerRadiusTopRight`, `cornerRadiusBottomRight`, `cornerRadiusBottomLeft`, `volume`, `color`, `offset`, `blur`, `value`, and on a [`<path>`](./path.md) `d`, `trimStart`, `trimEnd`, `trimOffset`. Whose prop is the track's holder's: a track under a [paint or color stop](./paints.md) animates the paint (`color`, `opacity`, `offset`), and one under a [`<stroke>`, `<shadow>` or `<effect>`](./styles.md) that style's own — `width` is a stroke's line width, `blur`/`offsetX`/`offsetY` a shadow's, `value` an effect's amount. A `d` track morphs a path's outline from one keyframe's path data to the next (see [path.md](./path.md#animating-the-outline)). For preset in/out effects (fade, slides, text reveals, ...) use [`<animation>`](./animations.md) instead.+Animatable props (`property`): `x`, `y`, `offsetX`, `offsetY`, `width`, `height`, `rotation`, `scale`, `scaleX`, `scaleY`, `opacity`, `cornerRadius`, `cornerRadiusTopLeft`, `cornerRadiusTopRight`, `cornerRadiusBottomRight`, `cornerRadiusBottomLeft`, `volume`, `color`, `offset`, `blur`, `value`, on a [`<path>`](./path.md) `d`, `trimStart`, `trimEnd`, `trimOffset`, and on a [`<stroke>`](./styles.md#dashes) `dash`, `dashGap`, `dashOffset`. Whose prop is the track's holder's: a track under a [paint or color stop](./paints.md) animates the paint (`color`, `opacity`, `offset`), and one under a [`<stroke>`, `<shadow>` or `<effect>`](./styles.md) that style's own — `width` is a stroke's line width, `blur`/`offsetX`/`offsetY` a shadow's, `value` an effect's amount. A `d` track morphs a path's outline from one keyframe's path data to the next (see [path.md](./path.md#animating-the-outline)). For preset in/out effects (fade, slides, text reveals, ...) use [`<animation>`](./animations.md) instead.## Semanticsdiff --git a/docs/reference/jsx/styles.md b/docs/reference/jsx/styles.mdindex 1b5b56a7..1db086d3 100644--- a/docs/reference/jsx/styles.md+++ b/docs/reference/jsx/styles.md@@ -19,8 +19,11 @@ An outline of the parent's shape (its box, or the curve of an `<ellipse>`, the c| `color` | `string` | none | Any CSS color; alpha is ignored (use `opacity`). Without it the stroke is drawn by its paint children alone. || `width` | `number` | `1` | Line width, px. A `width` [keyframe track](./keyframes.md) under a stroke drives this, not a box. || `join` | `"miter" \| "round" \| "bevel"` | `"miter"` | How the stroke turns corners. |-| `cap` | `"butt" \| "round" \| "square"` | `"butt"` | How the stroke ends open paths (text glyphs, open subpaths of a [`<path>`](./path.md)). |+| `cap` | `"butt" \| "round" \| "square"` | `"butt"` | How the stroke ends open paths (text glyphs, open subpaths of a [`<path>`](./path.md)) and each of its dashes. || `miterLimit` | `number` | `10` | Miter length limit, as a ratio of the width. |+| `dash` | `number` | `0` | Dash length, px: the line is drawn `dash` on, `dashGap` off, repeated. Solid while both are `0`. |+| `dashGap` | `number` | `dash` | Gap between dashes, px. `0` is a solid line. Unset, it is `dash` as written: a `dash` track does not move it. |+| `dashOffset` | `number` | `0` | How far into the dash pattern the line starts, px (SVG's `stroke-dashoffset`). || `opacity` | `number` | `1` | `0`–`1`, over `color` and every paint child. || `blendMode` | `BlendMode` | `"sourceOver"` | How the stroke composites. || `hidden` | `boolean` | absent | Excludes the stroke without removing it. |@@ -38,6 +41,21 @@ An outline of the parent's shape (its box, or the curve of an `<ellipse>`, the c</rect>```+### Dashes++`dash` and `dashGap` cut the line into dashes, measured along it in the same px as `width`; `<stroke dash={12} />` draws 12px dashes with 12px gaps. A `"round"` or `"square"` `cap` reaches half the width past both ends of every dash, into the gaps, so `dash={0}` with `cap="round"` draws dots. The pattern starts where each outline starts (a `<path>`'s after its trim), and `dashOffset` slides it: a growing `dashOffset` walks the dashes back toward the start, so a keyframe track on it makes marching ants. `dash`, `dashGap` and `dashOffset` are all [animatable](./keyframes.md) under a stroke, and a stroke is dashed only while one of them is written on it: a track alone leaves the line solid. The stroke is hit along its whole outline, gaps included.++```tsx+<rect width={640} height={360} cornerRadius={24}>+ <stroke color="#FFFFFF" width={4} cap="round" dash={16} dashGap={10}>+ <keyframeTrack property="dashOffset">+ <keyframe time={0} value={0} />+ <keyframe time={1} value={-52} />+ </keyframeTrack>+ </stroke>+</rect>+```+## `<shadow>`A drop shadow beneath the parent's silhouette: a blurred, offset copy of it in `color`.diff --git a/packages/jsx/src/types.ts b/packages/jsx/src/types.tsindex 5a377885..7ea82d19 100644--- a/packages/jsx/src/types.ts+++ b/packages/jsx/src/types.ts@@ -102,7 +102,8 @@ export type Easing =/*** The props a `<keyframeTrack>` can drive, by name. Whose prop is the* track's holder's: `x` under a `<rect>` is the rect's, `width` under a- * `<stroke>` the line width, `value` under an `<effect>` its amount,+ * `<stroke>` the line width (and `dash`/`dashGap`/`dashOffset` only go+ * under a stroke), `value` under an `<effect>` its amount,* `color`/`opacity` under a paint the paint's. `d` morphs a `<path>`'s* outline from one keyframe's path data to the next.*/@@ -139,7 +140,10 @@ export type AnimatableProperty =| "d"| "trimStart"| "trimEnd"- | "trimOffset";+ | "trimOffset"+ | "dash"+ | "dashGap"+ | "dashOffset";/** Transition styles — the editor's transition inspector options. */export type TransitionType =@@ -684,8 +688,8 @@ export type PathProps = CommonProps & FillProps & {/*** `<stroke>` — an outline of the parent's box (or glyphs), a sub-entity like a- * paint: `color` is its own solid paint, `width`/`join`/`cap`/`miterLimit` its- * line style, and paint children (`<SolidPaint>`, `<LinearGradientPaint>`,+ * paint: `color` is its own solid paint, `width`/`join`/`cap`/`miterLimit` and+ * `dash`/`dashGap`/`dashOffset` its line style, and paint children (`<SolidPaint>`, `<LinearGradientPaint>`,* `<RadialGradientPaint>`, `<AngularGradientPaint>`) draw through the same* line over `color`, placed in the parent's box. `opacity` and `blendMode`* apply to all of it. Several stack in document order, later ones on top.@@ -697,10 +701,31 @@ export type StrokeProps = Partial<ColorProps> & PaintProps & {width?: number;/** How the stroke turns corners. Default "miter". */join?: StrokeJoin;- /** How the stroke ends open paths (text glyphs, open `<path>` subpaths). Default "butt". */+ /**+ * How the stroke ends open paths (text glyphs, open `<path>` subpaths) and+ * each of its dashes. "round" and "square" reach half the width past the+ * end, into the gap. Default "butt".+ */cap?: StrokeCap;/** Miter length limit, as a ratio of the width. Default 10. */miterLimit?: number;+ /**+ * Dashes the line: `dash` px of line, then `dashGap` px of gap, repeated+ * along it. Default 0, a solid line unless `dashGap` is set; `dash={0}`+ * with `cap="round"` draws dots.+ */+ dash?: number;+ /**+ * The gap between dashes, px. Default `dash` as written (a `dash` track+ * does not move it); 0 is a solid line.+ */+ dashGap?: number;+ /**+ * How far into the dash pattern the line starts, px: SVG's+ * `stroke-dashoffset`. Animating it walks the dashes along the line, back+ * toward the start as it grows. Default 0.+ */+ dashOffset?: number;};/**diff --git a/packages/reconciler/src/document.ts b/packages/reconciler/src/document.tsindex 221a52e6..c5352371 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, clampPointCount, createEntity, DEFAULT_BACKGROUND, Color, ColorStop, Delay, Effect, EffectType, EvenOdd, Expanded, FontStyle, FramePromises, FrameRate, getActiveEntity, Loop, LoadRequest, Mask, Geometry, GeometryType, getEntityTree, getParentEntity, getParentNode, Hidden, Host, IsClipPath, isText, ItemIndex, KeepAspectRatio, Keyframe, KeyframeTrack, LINEAR_GRADIENT_DEFAULTS, LinearGradient, MixedCornerRadius, Mode, Muted, Name, Offset, Opacity, Pivot, Paint, PaintType, parseColor, parsePath, PathTrim, PendingSource, PendingSync, Playback, PlaybackRate, PointCount, Position, ELLIPTICAL_GRADIENT_DEFAULTS, EllipticalGradient, 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, Transition, TransitionType, Trim, UniformScale, VectorPath, ViewBox, 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, clampPointCount, createEntity, DEFAULT_BACKGROUND, Color, ColorStop, Delay, Effect, EffectType, EvenOdd, Expanded, FontStyle, FramePromises, FrameRate, getActiveEntity, Loop, LoadRequest, Mask, Geometry, GeometryType, getEntityTree, getParentEntity, getParentNode, Hidden, Host, IsClipPath, isText, ItemIndex, KeepAspectRatio, Keyframe, KeyframeTrack, LINEAR_GRADIENT_DEFAULTS, LinearGradient, MixedCornerRadius, Mode, Muted, Name, Offset, Opacity, Pivot, Paint, PaintType, parseColor, parsePath, PathTrim, PendingSource, PendingSync, Playback, PlaybackRate, PointCount, Position, ELLIPTICAL_GRADIENT_DEFAULTS, EllipticalGradient, 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, StrokeDash, StrokeJoin, StrokeStyle, SyncRequest, TextAlign, TextBaseline, TextCase, TextRange, TextStyle, Transition, TransitionType, Trim, UniformScale, VectorPath, ViewBox, 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';@@ -211,6 +211,9 @@ const TRACK_PROPERTIES: Record<string, PropertyPath> = {trimStart: 'trim.start',trimEnd: 'trim.end',trimOffset: 'trim.offset',+ dash: 'stroke.dash',+ dashGap: 'stroke.dashGap',+ dashOffset: 'stroke.dashOffset',};/**@@ -1202,6 +1205,27 @@ export class RuntimeDocument implements ProjectDocument<SceneNode> {entity.set(StrokeStyle, { miterLimit: toNumber(value) ?? 10 });return;}+ case 'dash':+ case 'dashGap':+ case 'dashOffset': {+ if (!entity.has(Stroke)) return;+ const dash = toNumber(node.props.dash);+ const gap = toNumber(node.props.dashGap);+ const offset = toNumber(node.props.dashOffset);+ if (dash === undefined && gap === undefined && offset === undefined) {+ entity.remove(StrokeDash);+ return;+ }+ // An unset gap is the dash length as written; a `dash` track+ // leaves it there.+ entity.add(StrokeDash);+ entity.set(StrokeDash, {+ dash: Math.max(0, dash ?? 0),+ gap: Math.max(0, gap ?? dash ?? 0),+ offset: offset ?? 0,+ });+ return;+ }case 'type': {if (entity.has(Animation)) {const type = typeof value === 'string' ? ANIMATION_TYPES[value] : undefined;diff --git a/packages/runtime/src/systems/motion.ts b/packages/runtime/src/systems/motion.tsindex e0bd8126..453edcb2 100644--- a/packages/runtime/src/systems/motion.ts+++ b/packages/runtime/src/systems/motion.ts@@ -10,7 +10,7 @@ import {Geometry, Group, AdjustmentLayer, Hidden, Culled,Computed, Cache, Animation, KeyframeTrack, Keyframe, Chars,UniformScale, Position, Offset, Rotation, Scale, Skew, Size, Opacity,- Color, Blur, Volume, Effect, StrokeStyle, CornerRadius, MixedCornerRadius,+ Color, Blur, Volume, Effect, StrokeStyle, StrokeDash, CornerRadius, MixedCornerRadius,ColorStop, LinearGradient, EllipticalGradient, PathTrim, VectorPath,} from '../traits';import { AnimationType, AnimationPhase, LINEAR_GRADIENT_DEFAULTS, ELLIPTICAL_GRADIENT_DEFAULTS } from '../constants';@@ -51,6 +51,9 @@ export function resetAnimatedValues(world: World, entity: Entity | null, ignore?computed.blur[eid] = read(Blur, 'value', 0);computed.volume[eid] = read(Volume, 'value', 0);computed.strokeWidth[eid] = read(StrokeStyle, 'width', 1);+ computed.dash[eid] = read(StrokeDash, 'dash', 0);+ computed.dashGap[eid] = read(StrokeDash, 'gap', 0);+ computed.dashOffset[eid] = read(StrokeDash, 'offset', 0);computed.cornerRadius[eid] = read(CornerRadius, 'value', 0);computed.cornerRadiusTopLeft[eid] = read(MixedCornerRadius, 'topLeft', 0);computed.cornerRadiusTopRight[eid] = read(MixedCornerRadius, 'topRight', 0);@@ -357,6 +360,18 @@ export function getPropertyPaths(world: World) {computed: computed.strokeWidth,authored: store(world, StrokeStyle).width,},+ 'stroke.dash': {+ computed: computed.dash,+ authored: store(world, StrokeDash).dash,+ },+ 'stroke.dashGap': {+ computed: computed.dashGap,+ authored: store(world, StrokeDash).gap,+ },+ 'stroke.dashOffset': {+ computed: computed.dashOffset,+ authored: store(world, StrokeDash).offset,+ },'vertexRadius': {computed: computed.cornerRadius,authored: store(world, CornerRadius).value,diff --git a/packages/runtime/src/systems/render.ts b/packages/runtime/src/systems/render.tsindex d80b2fd0..dd48e8c2 100644--- a/packages/runtime/src/systems/render.ts+++ b/packages/runtime/src/systems/render.ts@@ -34,7 +34,7 @@ import { getViewMatrix } from '../queries/camera';import { colorToHex } from '../utils/color';import { FAILED_COLOR, getSourceFailure } from '../utils/source-failure';import { getGeneratingColor, isGenerating } from '../utils/generating';-import { applyStrokeStyle } from '../utils/stroke';+import { applyStrokeStyle, clearLineDash } from '../utils/stroke';import { renderText } from '../utils/text';import { getTransitionWindow } from '../utils/transition';import { drawOnto, getSurfaceContext } from '../utils/surface';@@ -638,6 +638,9 @@ function renderStrokes(world: World, entity: Entity): void {ctx.globalCompositeOperation = savedCO;ctx.globalAlpha = savedAlpha;}++ // Not to dash the node's children, nor its shimmer.+ clearLineDash(ctx);}// Stable empty list for strokes without paint children, so the render loop allocates none.diff --git a/packages/runtime/src/traits/derived.ts b/packages/runtime/src/traits/derived.tsindex 3c38c000..5b5b6c11 100644--- a/packages/runtime/src/traits/derived.ts+++ b/packages/runtime/src/traits/derived.ts@@ -31,6 +31,9 @@ export const Computed = trait({volume: 0,value: 0,strokeWidth: 0,+ dash: 0,+ dashGap: 0,+ dashOffset: 0,cornerRadius: 0,cornerRadiusTopLeft: 0,cornerRadiusTopRight: 0,diff --git a/packages/runtime/src/traits/style.ts b/packages/runtime/src/traits/style.tsindex c44b16f8..6d2b8965 100644--- a/packages/runtime/src/traits/style.ts+++ b/packages/runtime/src/traits/style.ts@@ -96,6 +96,11 @@ export const StrokeStyle = trait({miterLimit: 10,});+// A dashed stroke sub-entity: `dash` px of line then `gap` px of gap,+// repeated from `offset` px along the line. A gap of 0 is a solid line.+// Absent means solid.+export const StrokeDash = trait({ dash: 0, gap: 0, offset: 0 });+// Shader paint source (document data; the compiled host lives in ShaderHost).export const Shader = trait({code: '',diff --git a/packages/runtime/src/utils/stroke.ts b/packages/runtime/src/utils/stroke.tsindex 977979ea..06a51ebe 100644--- a/packages/runtime/src/utils/stroke.ts+++ b/packages/runtime/src/utils/stroke.ts@@ -4,27 +4,50 @@import { store } from '../world/store';import { StrokeCap, StrokeJoin } from '../constants';-import { StrokeStyle, Computed, Hidden } from '../traits';+import { StrokeStyle, StrokeDash, Computed, Hidden } from '../traits';import type { Entity, World } from 'koota';type Ctx = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;/**- * Sets the context's line style from a stroke sub-entity's StrokeStyle. The- * width comes from Computed (animatable); a stroke without the trait draws- * as the trait's defaults.+ * Sets the context's line style from a stroke sub-entity's StrokeStyle and+ * StrokeDash. The width and dashes come from Computed (animatable); a stroke+ * without StrokeStyle draws as its defaults, and without StrokeDash solid. The dash stays on `ctx` after the+ * stroke, so a caller not inside its own save/restore clears it after+ * (`clearLineDash`), before anything else strokes.*/export function applyStrokeStyle(ctx: Ctx, world: World, stroke: Entity): void {const style = store(world, StrokeStyle);+ const computed = store(world, Computed);const sid = stroke.id();- ctx.lineWidth = store(world, Computed).strokeWidth[sid] ?? 1;+ ctx.lineWidth = computed.strokeWidth[sid] ?? 1;ctx.lineJoin = StrokeJoin[style.join[sid] ?? StrokeJoin.MITER]!.toLowerCase() as CanvasLineJoin;ctx.lineCap = StrokeCap[style.cap[sid] ?? StrokeCap.BUTT]!.toLowerCase() as CanvasLineCap;ctx.miterLimit = style.miterLimit[sid] ?? 10;++ // Clamped, as an easing that overshoots can take either below 0, and the+ // canvas ignores a dash with a negative length, keeping the last one.+ const dash = Math.max(0, computed.dash[sid] ?? 0);+ const gap = Math.max(0, computed.dashGap[sid] ?? 0);++ if (stroke.has(StrokeDash) && gap > 0) {+ ctx.setLineDash([dash, gap]);+ ctx.lineDashOffset = computed.dashOffset[sid] ?? 0;+ } else {+ clearLineDash(ctx);+ }}+/** Back to a solid line, after strokes that may have set a dash. */+export function clearLineDash(ctx: Ctx): void {+ ctx.setLineDash(NO_DASH);+ ctx.lineDashOffset = 0;+}++const NO_DASH: number[] = [];+/*** The visible stroke of `strokes` drawn widest, or null when none is: what a* shadow of a stroked shape takes its silhouette from.diff --git a/packages/runtime/src/world/observers.ts b/packages/runtime/src/world/observers.tsindex 5c061f7f..485f7aac 100644--- a/packages/runtime/src/world/observers.ts+++ b/packages/runtime/src/world/observers.ts@@ -9,7 +9,7 @@ import {Delay, Trim, PlaybackRate, SourceFrameRate, Keyframe, ItemIndex,Position, Offset, Rotation, Scale, UniformScale, Skew, Anchor, Pivot, Flip,Opacity, Color, Blur, Volume, Effect, CornerRadius, MixedCornerRadius,- ColorStop, LinearGradient, EllipticalGradient, PathTrim, StrokeStyle, Size, Computed, Active, Stage, IsClipPath,+ ColorStop, LinearGradient, EllipticalGradient, PathTrim, StrokeStyle, StrokeDash, Size, Computed, Active, Stage, IsClipPath,ImageDecoderHandle, VideoDecoderHandle,AudioDecoderHandle, CaptionDecoderHandle, WaveformHandle,ShaderHostHandle, AudioBusHandle, TextStyle, TextRange,@@ -301,6 +301,14 @@ export function observeWorld(world: World): () => void {store(world, Computed).strokeWidth[entity.id()] = entity.get(StrokeStyle)!.width;});+ mirror(StrokeDash, (entity) => {+ const computed = store(world, Computed);+ const { dash, gap, offset } = entity.get(StrokeDash)!;+ computed.dash[entity.id()] = dash;+ computed.dashGap[entity.id()] = gap;+ computed.dashOffset[entity.id()] = offset;+ });+// Size flows into Computed via propagation (descendants owning a Size// re-derive too). Deserialize is a plain set, so the propagation rides on// the event rather than on whatever restored the size.diff --git a/packages/runtime/src/world/serialize.ts b/packages/runtime/src/world/serialize.tsindex 9e681472..fa008dd1 100644--- a/packages/runtime/src/world/serialize.ts+++ b/packages/runtime/src/world/serialize.ts@@ -11,7 +11,7 @@ import {Constraint, KeepAspectRatio,Opacity, BlendMode, Color, CornerRadius, MixedCornerRadius, PointCount, Blur, ScaleMode, Effect, Mask,VectorPath, EvenOdd, ViewBox, PathTrim,- ColorStop, LinearGradient, EllipticalGradient, StrokeStyle, Shader,+ ColorStop, LinearGradient, EllipticalGradient, StrokeStyle, StrokeDash, Shader,Chars, TextStyle,Delay, Trim, PlaybackRate, SourceFrameRate,Playback, Sequential, Transition, ClipHeight, Expanded,@@ -150,6 +150,7 @@ export interface EntityRecord {cap?: number;miterLimit?: number;};+ StrokeDash?: { dash: number; gap: number; offset: number };Hidden?: boolean;ClipsContent?: boolean;Sequential?: {};@@ -387,6 +388,10 @@ export function serializeEntity(entity: Entity): EntityRecord {miterLimit: stroke.miterLimit,};}+ if (entity.has(StrokeDash)) {+ const { dash, gap, offset } = entity.get(StrokeDash)!;+ record.StrokeDash = { dash, gap, offset };+ }if (entity.has(Hidden)) {record.Hidden = true;}@@ -673,6 +678,10 @@ export function deserializeEntity(entity: Entity, e: Partial<EntityRecord>): voientity.add(StrokeStyle);entity.set(StrokeStyle, defined(e.StrokeStyle));}+ if (e.StrokeDash !== undefined) {+ entity.add(StrokeDash);+ entity.set(StrokeDash, e.StrokeDash);+ }if (e.Hidden !== undefined) {entity.add(Hidden);}