The VS Code of video editing, built for agents.
TypeScript
Add stroke cap customization to StrokeInspector component
konstantin-paulusd6c76e690d34
diff --git a/apps/web/src/assets/icons/line-cap-butt.svg b/apps/web/src/assets/icons/line-cap-butt.svgnew file mode 100644index 00000000..9d786ff6--- /dev/null+++ b/apps/web/src/assets/icons/line-cap-butt.svg@@ -0,0 +1,4 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M19 7.5H6.5V17.5H19" stroke="currentColor"/>+<path opacity="0.5" d="M8 12.5H18" stroke="currentColor" stroke-dasharray="2 2"/>+</svg>diff --git a/apps/web/src/assets/icons/line-cap-round.svg b/apps/web/src/assets/icons/line-cap-round.svgnew file mode 100644index 00000000..cfc2c8c4--- /dev/null+++ b/apps/web/src/assets/icons/line-cap-round.svg@@ -0,0 +1,4 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M19 7.5H11.5A5 5 0 0 0 11.5 17.5H19" stroke="currentColor"/>+<path opacity="0.5" d="M12 12.5H18" stroke="currentColor" stroke-dasharray="2 2"/>+</svg>diff --git a/apps/web/src/assets/icons/line-cap-square.svg b/apps/web/src/assets/icons/line-cap-square.svgnew file mode 100644index 00000000..50cc890f--- /dev/null+++ b/apps/web/src/assets/icons/line-cap-square.svg@@ -0,0 +1,4 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M19 7.5H6.5V17.5H19" stroke="currentColor"/>+<path opacity="0.5" d="M12 12.5H18" stroke="currentColor" stroke-dasharray="2 2"/>+</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 0625ac33..ea9cad26 100644--- a/apps/web/src/components/sidebar-right/inspector/stroke-inspector.tsx+++ b/apps/web/src/components/sidebar-right/inspector/stroke-inspector.tsx@@ -28,14 +28,18 @@ import { IncrementDecrementControl } from "@/components/ui/increment-decrement-cimport { SegmentedIconTabs } from "@/components/ui/segmented-icon-tabs";import { Keyframe } from "@/components/ui/keyframe";import { useHas, useTrait, useWorld } from "@diffusionstudio/koota-solid";-import { Cache, Computed, StrokeDash, StrokeJoin, StrokeStyle } from "@diffusionstudio/runtime";+import { Cache, Computed, StrokeCap, StrokeDash, StrokeJoin, StrokeStyle } from "@diffusionstudio/runtime";import { useDerived, useEditor } from "@/engine/hooks";import { removeKeyframeTrack, syncKeyframe } from "@/engine/keyframes";import { FillPicker, type FillTab } from "./fill-picker";import type { Accessor } from "solid-js";-import type { AnimatableProperty, StrokeJoin as StrokeJoinName } from "@diffusionstudio/jsx";+import type {+ AnimatableProperty,+ StrokeCap as StrokeCapName,+ StrokeJoin as StrokeJoinName,+} from "@diffusionstudio/jsx";import type { Entity } from "koota";const JOIN_SEGMENTS: { value: StrokeJoinName; icon: string; label: string }[] = [@@ -44,6 +48,12 @@ const JOIN_SEGMENTS: { value: StrokeJoinName; icon: string; label: string }[] ={ value: "round", icon: "line-join-round", label: "Round" },];+const CAP_SEGMENTS: { value: StrokeCapName; icon: string; label: string }[] = [+ { value: "butt", icon: "line-cap-butt", label: "Butt" },+ { value: "round", icon: "line-cap-round", label: "Round" },+ { value: "square", icon: "line-cap-square", label: "Square" },+];+type LineStyle = "solid" | "dashed";const LINE_STYLES: LineStyle[] = ["solid", "dashed"];@@ -70,6 +80,12 @@ const JOIN_NAMES: Record<StrokeJoin, StrokeJoinName> = {[StrokeJoin.ROUND]: "round",};+const CAP_NAMES: Record<StrokeCap, StrokeCapName> = {+ [StrokeCap.BUTT]: "butt",+ [StrokeCap.ROUND]: "round",+ [StrokeCap.SQUARE]: "square",+};+/** A line is drawn with a color or a gradient, never a picture. */const STROKE_TABS: FillTab[] = ["solid", "gradient"];@@ -100,12 +116,12 @@ type StrokeInspectorProps = {};/**- * One `<stroke>`: its paint and its line style (`width`/`join`/`miterLimit`,+ * One `<stroke>`: its paint and its line style (`width`/`cap`/`join`/`miterLimit`,* and when the style select 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.+ * handles go.*/export function StrokeInspector(props: StrokeInspectorProps) {const world = useWorld();@@ -121,6 +137,7 @@ export function StrokeInspector(props: StrokeInspectorProps) {const style = useTrait(() => props.stroke, StrokeStyle);const join = createMemo(() => JOIN_NAMES[style()?.join ?? StrokeJoin.MITER]);+ const cap = createMemo(() => CAP_NAMES[style()?.cap ?? StrokeCap.BUTT]);const miterLimit = () => style()?.miterLimit ?? DEFAULT_MITER_LIMIT;const dash = useDerived(() => props.stroke.get(Computed)?.dash ?? DEFAULT_DASH);@@ -141,6 +158,10 @@ export function StrokeInspector(props: StrokeInspectorProps) {editor.editProperty(props.stroke, "join", value === "miter" ? false : value);};+ const editCap = (value: StrokeCapName) => {+ editor.editProperty(props.stroke, "cap", value === "butt" ? false : value);+ };+const editMiterLimit = (value: number) => {editor.editProperty(props.stroke,@@ -317,6 +338,16 @@ export function StrokeInspector(props: StrokeInspectorProps) {/></ControlRow>+ <ControlRow label="Cap">+ <SegmentedIconTabs+ value={cap}+ onChange={editCap}+ items={CAP_SEGMENTS}+ buttonClass="transition-colors"+ iconClass="text-muted-foreground"+ />+ </ControlRow>+<ControlRow label="Miter"><ControlledTextFieldicon={<Icon name="stroke.miter" />}