Skip to content

🎥 Make videos programmatically with React

Render lossless path outlines and disable bbox transform handles on them

Jonny Burgerbe9e161ae58a
diff --git a/packages/canvas/src/canvas-outline-polygon.tsx b/packages/canvas/src/canvas-outline-polygon.tsx
index 947c4c1710..b71dc1dc8e 100644
--- a/packages/canvas/src/canvas-outline-polygon.tsx
+++ b/packages/canvas/src/canvas-outline-polygon.tsx
@@ -1,4 +1,4 @@
-import React, {forwardRef, memo, useCallback, useMemo} from 'react';
+import React, {forwardRef, memo, useCallback, useId, useMemo} from 'react';
import type {CanvasOutline} from './outline-geometry';
export type CanvasOutlinePolygonProps = Omit<
@@ -46,14 +46,29 @@ export const CanvasOutlinePolygon = memo(
() => outline.points.map((point) => `${point.x},${point.y}`).join(' '),
[outline.points],
);
- const pathPointsAttr = useMemo(
+ // `useId()` contains characters that are unsafe inside `url(#...)`.
+ const clipId = `clip-${useId().replace(/[^a-zA-Z0-9]/g, '')}`;
+ // Like the element's own CSS `clip-path`, only clip the geometry when a
+ // crop is actually applied - otherwise a path running along its
+ // bounding box edge would lose half its stroke.
+ const isCropped = useMemo(() => {
+ const uncropped = outline.uncroppedPoints;
+ if (uncropped === null) {
+ return false;
+ }
+
+ return outline.points.some(
+ (point, index) =>
+ Math.abs(point.x - uncropped[index].x) > 0.01 ||
+ Math.abs(point.y - uncropped[index].y) > 0.01,
+ );
+ }, [outline.points, outline.uncroppedPoints]);
+ const matrixTransform = useMemo(
() =>
- outline.pathPoints === null
+ outline.path === null
? null
- : outline.pathPoints
- .map((point) => `${point.x},${point.y}`)
- .join(' '),
- [outline.pathPoints],
+ : `matrix(${outline.path.matrix.a} ${outline.path.matrix.b} ${outline.path.matrix.c} ${outline.path.matrix.d} ${outline.path.matrix.e} ${outline.path.matrix.f})`,
+ [outline.path],
);
const onPointerEnter = useCallback(() => {
if (!dragging) {
@@ -68,6 +83,13 @@ export const CanvasOutlinePolygon = memo(
return (
<g>
+ {matrixTransform === null || !isCropped ? null : (
+ <defs>
+ <clipPath id={clipId}>
+ <polygon points={points} />
+ </clipPath>
+ </defs>
+ )}
<polygon
{...props}
ref={ref}
@@ -77,7 +99,7 @@ export const CanvasOutlinePolygon = memo(
}
points={points}
fill={fill}
- stroke={pathPointsAttr === null ? stroke : 'transparent'}
+ stroke={matrixTransform === null ? stroke : 'transparent'}
strokeOpacity={visible ? 1 : 0}
strokeWidth={2}
vectorEffect="non-scaling-stroke"
@@ -85,9 +107,11 @@ export const CanvasOutlinePolygon = memo(
onPointerEnter={onPointerEnter}
onPointerLeave={onPointerLeave}
/>
- {pathPointsAttr === null ? null : (
- <polyline
- points={pathPointsAttr}
+ {matrixTransform === null ? null : (
+ <path
+ d={outline.path?.d ?? ''}
+ transform={matrixTransform}
+ clipPath={isCropped ? `url(#${clipId})` : undefined}
fill="none"
stroke={stroke}
strokeOpacity={visible ? 1 : 0}
diff --git a/packages/canvas/src/index.ts b/packages/canvas/src/index.ts
index c4f2c1df58..218f76167d 100644
--- a/packages/canvas/src/index.ts
+++ b/packages/canvas/src/index.ts
@@ -15,6 +15,8 @@ export type {
CanvasOutlinePoint,
CanvasOutlineUv,
CanvasOutlineCrop,
+ CanvasOutlineMatrix,
+ CanvasOutlinePath,
CanvasOutlineTarget,
} from './outline-geometry';
export {getCanvasOutlinePoint, getCanvasOutlineUv} from './outline-geometry';
diff --git a/packages/canvas/src/outline-geometry.ts b/packages/canvas/src/outline-geometry.ts
index 4cabb2eed2..0e33ca2eb9 100644
--- a/packages/canvas/src/outline-geometry.ts
+++ b/packages/canvas/src/outline-geometry.ts
@@ -25,11 +25,28 @@ export type CanvasOutline = {
CanvasOutlinePoint,
];
/**
- * Samples along the actual geometry of an SVG path, in the same space as
- * `points` (already cropped). Null for non-path elements, or when the
- * geometry cannot be sampled.
+ * The SVG geometry of a path element, in the same space as
+ * `uncroppedPoints`. Crop is not baked in — like the CSS `clip-path`
+ * applied to the element, it clips the geometry at render time. Null for
+ * non-path elements, or when the geometry cannot be read.
*/
- readonly pathPoints: readonly CanvasOutlinePoint[] | null;
+ readonly path: CanvasOutlinePath | null;
+};
+
+/** Affine transform mapping SVG user units to overlay container pixels. */
+export type CanvasOutlineMatrix = {
+ readonly a: number;
+ readonly b: number;
+ readonly c: number;
+ readonly d: number;
+ readonly e: number;
+ readonly f: number;
+};
+
+/** The exact geometry of an SVG path element, without sampling. */
+export type CanvasOutlinePath = {
+ readonly d: string;
+ readonly matrix: CanvasOutlineMatrix;
};
const mix = (from: number, to: number, progress: number): number => {
diff --git a/packages/canvas/src/outline-interaction.ts b/packages/canvas/src/outline-interaction.ts
index afe3c7033e..1ff85f4c54 100644
--- a/packages/canvas/src/outline-interaction.ts
+++ b/packages/canvas/src/outline-interaction.ts
@@ -73,31 +73,48 @@ export const handleCanvasOutlinePointerDown = ({
const ownerSvg = polygon?.ownerSVGElement;
let pointerInsideSelectedOutline = false;
if (ownerSvg) {
- const screenPoint = ownerSvg.createSVGPoint();
- screenPoint.x = event.clientX;
- screenPoint.y = event.clientY;
pointerInsideSelectedOutline = Array.from(
ownerSvg.querySelectorAll<SVGPolygonElement>(
'polygon[data-remotion-directly-selected-outline="true"]',
),
).some((selectedPolygon) => {
- const screenTransform = selectedPolygon.getScreenCTM();
- if (screenTransform === null) {
+ // Map the pointer into the polygon's local space without
+ // `getScreenCTM()`: the overlay lives inside Studio's fit-scale
+ // ancestor, whose CSS transform WebKit's getScreenCTM() ignores.
+ // A uniformly-scaled rect (the only case here — the overlay svg is
+ // unscaled and CSS transforms above it are fit scales/translations)
+ // is inverted via the bounding rect.
+ const rect = selectedPolygon.getBoundingClientRect();
+ if (rect.width === 0 && rect.height === 0) {
return false;
}
- // A collapsed transform has no hittable area and cannot be inverted.
- if (
- screenTransform.a * screenTransform.d -
- screenTransform.b * screenTransform.c ===
- 0
- ) {
+ const bbox = selectedPolygon.getBBox();
+ if (bbox.width === 0 && bbox.height === 0) {
return false;
}
- const polygonPoint = screenPoint.matrixTransform(
- screenTransform.inverse(),
- );
+ const scaleX = rect.width / bbox.width;
+ const scaleY = rect.height / bbox.height;
+ if (!Number.isFinite(scaleX) || !Number.isFinite(scaleY)) {
+ return false;
+ }
+
+ // A collapsed or anisotropically distorted outline has no reliable
+ // inverse; treat it as unhittable, like a collapsed CTM before.
+ if (Math.abs(scaleX) < 1e-6 || Math.abs(scaleY) < 1e-6) {
+ return false;
+ }
+
+ const localX = (event.clientX - rect.left) / scaleX + bbox.x;
+ const localY = (event.clientY - rect.top) / scaleY + bbox.y;
+ if (!Number.isFinite(localX) || !Number.isFinite(localY)) {
+ return false;
+ }
+
+ const polygonPoint = ownerSvg.createSVGPoint();
+ polygonPoint.x = localX;
+ polygonPoint.y = localY;
return (
selectedPolygon.isPointInFill(polygonPoint) ||
selectedPolygon.isPointInStroke(polygonPoint)
diff --git a/packages/canvas/src/outline-measurement.ts b/packages/canvas/src/outline-measurement.ts
index 1c61f756f9..e29823a38f 100644
--- a/packages/canvas/src/outline-measurement.ts
+++ b/packages/canvas/src/outline-measurement.ts
@@ -1,11 +1,15 @@
-import {useCache as resetBoxQuadsCache} from './get-box-quads-polyfill-internals.js';
+import {
+ getResultingTransformationBetweenElementAndAllAncestors,
+ useCache as resetBoxQuadsCache,
+} from './get-box-quads-polyfill-internals.js';
import {getBoxQuadsPonyfill} from './get-box-quads-ponyfill';
import type {
CanvasOutline,
CanvasOutlinePoint,
+ CanvasOutlinePath,
CanvasOutlineTarget,
} from './outline-geometry';
-import {getCanvasOutlinePoint, getCanvasOutlineUv} from './outline-geometry';
+import {getCanvasOutlinePoint} from './outline-geometry';
const rectToPoints = (
elementRect: DOMRect,
@@ -107,19 +111,166 @@ const getSvgSvgElementViewport = (element: SVGSVGElement): SvgViewport => {
};
};
+/**
+ * Maps SVG user units to viewport pixels, including ancestor CSS transforms.
+ *
+ * `getScreenCTM()` is the obvious API for this, but WebKit ignores ancestor
+ * CSS transforms in it, while Blink/Gecko include them — so a Studio fit-scale
+ * wrapper would make the outline render at the wrong size in Safari. Instead
+ * we compose two consistent transforms:
+ *
+ * 1. The polyfill's CSS-transform-aware walk from the root <svg> to the
+ * document element (document coordinates, no viewport scroll — FIX 15).
+ * 2. `element.getCTM()`, the pure SVG-internal transform from user units to
+ * the root <svg>'s viewport. Cross-browser consistent, no CSS involved.
+ *
+ * Finally we mirror `toViewportRelativeDocumentElementQuad`: subtract window
+ * scroll to land in viewport coordinates, then subtract the overlay origin
+ * (like `quadToPoints` does for HTML quads).
+ */
+const getSvgElementScreenMatrix = (
+ element: SVGGraphicsElement,
+): (SvgScreenCtm & {readonly is2D: boolean}) | null => {
+ const ownerSvg = element.ownerSVGElement;
+ const {documentElement} = element.ownerDocument;
+ const win = element.ownerDocument.defaultView;
+ if (!ownerSvg || !documentElement || !win) {
+ return null;
+ }
+
+ let walk;
+ try {
+ // Walking the root <svg> (not the path) avoids the polyfill's
+ // bbox-translate branch for SVG children, which would shift the
+ // coordinates by the path's `getBBox()` origin.
+ walk = getResultingTransformationBetweenElementAndAllAncestors(
+ ownerSvg,
+ documentElement,
+ [],
+ );
+ } catch {
+ // Mirrors getBoxQuadsPonyfill's try/catch contract for exotic DOMs.
+ return null;
+ }
+
+ const ctm = element.getCTM();
+ if (ctm === null) {
+ return null;
+ }
+
+ const matrix = walk.multiply(ctm);
+ const scrollX = win.scrollX ?? documentElement.scrollLeft ?? 0;
+ const scrollY = win.scrollY ?? documentElement.scrollTop ?? 0;
+
+ return {
+ a: matrix.a,
+ b: matrix.b,
+ c: matrix.c,
+ d: matrix.d,
+ e: matrix.e - scrollX,
+ f: matrix.f - scrollY,
+ is2D: matrix.is2D,
+ };
+};
+
const getSvgSvgElementOutlinePoints = (
element: SVGSVGElement,
containerRect: DOMRect,
): CanvasOutline['points'] | null => {
- const ctm = element.getScreenCTM();
const viewport = getSvgSvgElementViewport(element);
- if (ctm === null || (viewport.width === 0 && viewport.height === 0)) {
+ if (viewport.width === 0 && viewport.height === 0) {
+ return null;
+ }
+
+ const {documentElement} = element.ownerDocument;
+ const win = element.ownerDocument.defaultView;
+ if (!documentElement || !win) {
+ return null;
+ }
+
+ let walk;
+ try {
+ // The walk on the root <svg> includes its own CSS transform, unlike
+ // `getScreenCTM()` in WebKit, which ignores ancestor CSS transforms.
+ walk = getResultingTransformationBetweenElementAndAllAncestors(
+ element,
+ documentElement,
+ [],
+ );
+ } catch {
+ // Mirrors getBoxQuadsPonyfill's try/catch contract for exotic DOMs.
+ return null;
+ }
+
+ if (!walk.is2D) {
return null;
}
+ // Compose the viewBox→viewport transform manually: root-svg `getCTM()`
+ // semantics are unreliable across browsers, and this keeps the math
+ // dependency-free. `walk` maps viewport px → document coordinates.
+ const viewBox = element.viewBox.baseVal;
+ const hasViewBox = viewBox.width > 0 && viewBox.height > 0;
+ const viewportWidth = element.width.baseVal.value;
+ const viewportHeight = element.height.baseVal.value;
+
+ let scaleX = 1;
+ let scaleY = 1;
+ let translateX = 0;
+ let translateY = 0;
+ if (hasViewBox) {
+ // SVG_PRESERVEASPECTRATIO_NONE = 1, XMINYMIN = 2 … XMAXYMAX = 10;
+ // SVG_MEETORSLICE_MEET = 1, SVG_MEETORSLICE_SLICE = 2.
+ const {align, meetOrSlice} = element.preserveAspectRatio.baseVal;
+ if (align === 1) {
+ scaleX = viewportWidth / viewBox.width;
+ scaleY = viewportHeight / viewBox.height;
+ } else {
+ const uniform =
+ meetOrSlice === 2
+ ? Math.max(
+ viewportWidth / viewBox.width,
+ viewportHeight / viewBox.height,
+ )
+ : Math.min(
+ viewportWidth / viewBox.width,
+ viewportHeight / viewBox.height,
+ );
+ scaleX = uniform;
+ scaleY = uniform;
+ // x alignment: align % 3 → 2 = xMin, 0 = xMid, 1 = xMax.
+ translateX =
+ align % 3 === 0
+ ? (viewportWidth - viewBox.width * uniform) / 2
+ : align % 3 === 1
+ ? viewportWidth - viewBox.width * uniform
+ : 0;
+ // y alignment: YMIN = 2–4, YMID = 5–7, YMAX = 8–10.
+ translateY =
+ align <= 4
+ ? 0
+ : align <= 7
+ ? (viewportHeight - viewBox.height * uniform) / 2
+ : viewportHeight - viewBox.height * uniform;
+ }
+
+ translateX -= viewBox.x * scaleX;
+ translateY -= viewBox.y * scaleY;
+ }
+
+ const scrollX = win.scrollX ?? documentElement.scrollLeft ?? 0;
+ const scrollY = win.scrollY ?? documentElement.scrollTop ?? 0;
+
return getTransformedSvgViewportPoints({
viewport,
- ctm,
+ ctm: {
+ a: walk.a * scaleX,
+ b: walk.b * scaleX,
+ c: walk.c * scaleY,
+ d: walk.d * scaleY,
+ e: walk.a * translateX + walk.c * translateY + walk.e - scrollX,
+ f: walk.b * translateX + walk.d * translateY + walk.f - scrollY,
+ },
containerRect,
});
};
@@ -134,42 +285,38 @@ const isSvgPathElement = (element: Element): element is SVGPathElement => {
);
};
-const pathSampleSpacing = 8;
-const maxPathSamples = 400;
-
-const getPathPoints = ({
+const getPathOutline = ({
element,
containerRect,
}: {
readonly element: SVGPathElement;
readonly containerRect: DOMRect;
-}): readonly CanvasOutlinePoint[] | null => {
- const ctm = element.getScreenCTM();
- if (ctm === null) {
+}): CanvasOutlinePath | null => {
+ const d = element.getAttribute('d');
+ if (d === null || d === '') {
return null;
}
- const totalLength = element.getTotalLength();
- if (totalLength === 0) {
+ const ctm = getSvgElementScreenMatrix(element);
+ if (ctm === null || !ctm.is2D) {
+ // In a 3D CSS context no single 2D matrix can place the path; the
+ // polygon outline from `getBoxQuads` still applies.
return null;
}
- const count = Math.min(
- maxPathSamples,
- Math.max(2, Math.ceil(totalLength / pathSampleSpacing) + 1),
- );
- const points: CanvasOutlinePoint[] = [];
- for (let i = 0; i < count; i++) {
- // Walk the length so each sample is equidistant along the geometry.
- const length = (totalLength * i) / (count - 1);
- const point = element.getPointAtLength(length);
- points.push({
- x: ctm.a * point.x + ctm.c * point.y + ctm.e - containerRect.left,
- y: ctm.b * point.x + ctm.d * point.y + ctm.f - containerRect.top,
- });
- }
-
- return points;
+ // Shift the translation into the overlay svg's local space, like every
+ // other point source.
+ return {
+ d,
+ matrix: {
+ a: ctm.a,
+ b: ctm.b,
+ c: ctm.c,
+ d: ctm.d,
+ e: ctm.e - containerRect.left,
+ f: ctm.f - containerRect.top,
+ },
+ };
};
const getElementOutlinePoints = (
@@ -233,33 +380,6 @@ export const cropCanvasOutlinePoints = (
];
};
-const cropPathPoints = (
- pathPoints: readonly CanvasOutlinePoint[],
- uncroppedPoints: CanvasOutline['uncroppedPoints'],
- crop: CanvasOutlineTarget['crop'],
-): readonly CanvasOutlinePoint[] => {
- if (
- crop.left === 0 &&
- crop.right === 0 &&
- crop.top === 0 &&
- crop.bottom === 0
- ) {
- return pathPoints;
- }
-
- if (uncroppedPoints === null) {
- return pathPoints;
- }
-
- return pathPoints.map((point) => {
- const uv = getCanvasOutlineUv(uncroppedPoints, point);
- return getCanvasOutlinePoint(
- cropCanvasOutlinePoints(uncroppedPoints, crop),
- uv,
- );
- });
-};
-
/**
* Measures a batch against an unscaled overlay container. Shared ancestor
* transforms are cached only within this measurement batch.
@@ -291,13 +411,8 @@ export const measureCanvasOutlineTargets = (
const points = cropCanvasOutlinePoints(uncroppedPoints, target.crop);
const ownerHTMLElement = element.ownerDocument.defaultView?.HTMLElement;
- const pathPoints = isSvgPathElement(element)
- ? (() => {
- const sampled = getPathPoints({element, containerRect});
- return sampled === null
- ? null
- : cropPathPoints(sampled, uncroppedPoints, target.crop);
- })()
+ const path = isSvgPathElement(element)
+ ? getPathOutline({element, containerRect})
: null;
outlines.push({
@@ -318,7 +433,7 @@ export const measureCanvasOutlineTargets = (
: null,
uncroppedPoints,
points,
- pathPoints,
+ path,
});
}
@@ -362,24 +477,26 @@ export const canvasOutlinesAreEqual = (
}
}
- const aPathPoints = a[i].pathPoints;
- const bPathPoints = b[i].pathPoints;
- if ((aPathPoints === null) !== (bPathPoints === null)) {
+ const aPath = a[i].path;
+ const bPath = b[i].path;
+ if ((aPath === null) !== (bPath === null)) {
return false;
}
- if (aPathPoints !== null && bPathPoints !== null) {
- if (aPathPoints.length !== bPathPoints.length) {
+ if (aPath !== null && bPath !== null) {
+ if (aPath.d !== bPath.d) {
return false;
}
- for (let j = 0; j < aPathPoints.length; j++) {
- if (
- Math.abs(aPathPoints[j].x - bPathPoints[j].x) > 0.01 ||
- Math.abs(aPathPoints[j].y - bPathPoints[j].y) > 0.01
- ) {
- return false;
- }
+ if (
+ Math.abs(aPath.matrix.a - bPath.matrix.a) > 0.01 ||
+ Math.abs(aPath.matrix.b - bPath.matrix.b) > 0.01 ||
+ Math.abs(aPath.matrix.c - bPath.matrix.c) > 0.01 ||
+ Math.abs(aPath.matrix.d - bPath.matrix.d) > 0.01 ||
+ Math.abs(aPath.matrix.e - bPath.matrix.e) > 0.01 ||
+ Math.abs(aPath.matrix.f - bPath.matrix.f) > 0.01
+ ) {
+ return false;
}
}
diff --git a/packages/studio/src/components/SelectedOutlineEditingHandles.tsx b/packages/studio/src/components/SelectedOutlineEditingHandles.tsx
index c1f908328d..fa4bfc29e0 100644
--- a/packages/studio/src/components/SelectedOutlineEditingHandles.tsx
+++ b/packages/studio/src/components/SelectedOutlineEditingHandles.tsx
@@ -56,6 +56,11 @@ export const SelectedOutlineEditingHandles: React.FC<{
() => getSelectedOutlineControlLayout(outline.points),
[outline.points],
);
+ // Scale and rotation handles are placed on the bounding box of the element.
+ // For path outlines the rendered geometry follows the SVG path, so
+ // bounding-box handles would sit off the shape and misrepresent the
+ // transform. Translate and crop still apply to the element as a whole.
+ const showTransformHandles = outline.path === null;
const onContextMenuOpen = React.useCallback(() => {
return getContextMenuOpenByKey(outline.key)?.() ?? false;
}, [getContextMenuOpenByKey, outline.key]);
@@ -67,7 +72,8 @@ export const SelectedOutlineEditingHandles: React.FC<{
onDraggingChange={onDraggingChange}
target={controlTarget}
/>
- {controlTarget?.cropDrag === null &&
+ {showTransformHandles &&
+ controlTarget?.cropDrag === null &&
(layoutTarget?.containsSelection || hovered)
? controlLayout.scaleEdges.map((edge) => (
<SelectedOutlineScaleEdgeLine
@@ -90,7 +96,8 @@ export const SelectedOutlineEditingHandles: React.FC<{
/>
))
: null}
- {controlTarget?.cropDrag === null &&
+ {showTransformHandles &&
+ controlTarget?.cropDrag === null &&
(layoutTarget?.containsSelection || hovered)
? controlLayout.rotationCorners.map(({corner, point}) => (
<SelectedOutlineRotationCornerHandle
diff --git a/packages/studio/src/components/SelectedOutlineElement.tsx b/packages/studio/src/components/SelectedOutlineElement.tsx
index e7c51b4e72..9f3d9c9d34 100644
--- a/packages/studio/src/components/SelectedOutlineElement.tsx
+++ b/packages/studio/src/components/SelectedOutlineElement.tsx
@@ -240,7 +240,7 @@ const SelectedOutlineElementUnmemoized: React.FC<
!sourceEditDisabled &&
previewServerState.type === 'connected';
const canCrop = contextMenuTarget.canCrop && !sourceEditDisabled;
- const canRotate = !sourceEditDisabled;
+ const canRotate = !sourceEditDisabled && outline.path === null;
const outlineElement =
contextMenuTarget.sequence.refForOutline?.current ?? null;
return getSequenceContextMenuItems({
@@ -447,6 +447,7 @@ const SelectedOutlineElementUnmemoized: React.FC<
selectAsset,
setSelectedModal,
setPropStatuses,
+ outline.path,
]);
useLayoutEffect(() => {
registerContextMenuOpen(outline.key, onContextMenuOpen);
@@ -482,7 +483,9 @@ const SelectedOutlineElementUnmemoized: React.FC<
Boolean(controlTarget?.rotationDrag)
}
/>
- {layoutTarget?.selectedForRotation && controlTarget?.rotationDrag ? (
+ {layoutTarget?.selectedForRotation &&
+ controlTarget?.rotationDrag &&
+ outline.path === null ? (
<SelectedOutlineCanvasRotation
getLatestTargetByKey={getLatestTargetByKey}
layoutTarget={layoutTarget}
diff --git a/packages/studio/src/components/SelectedOutlineRenderer.tsx b/packages/studio/src/components/SelectedOutlineRenderer.tsx
index 78a01f3a66..7485fc8388 100644
--- a/packages/studio/src/components/SelectedOutlineRenderer.tsx
+++ b/packages/studio/src/components/SelectedOutlineRenderer.tsx
@@ -187,6 +187,12 @@ const SelectedOutlineRendererUnmemoized: React.FC<{
const getAllScaleDragTargets = useCallback(
() =>
targetsRef.current.flatMap((target) => {
+ const outline = outlinesByKeyRef.current.get(target.key);
+ if (outline !== undefined && outline.path !== null) {
+ // Path outlines do not render scale handles.
+ return [];
+ }
+
const scaleDrag = target.selected
? (getLatestOutlineTargetByKey(target.key)?.scaleDrag ?? null)
: null;
@@ -197,6 +203,12 @@ const SelectedOutlineRendererUnmemoized: React.FC<{
const getAllRotationDragTargets = useCallback(
() =>
targetsRef.current.flatMap((target) => {
+ const outline = outlinesByKeyRef.current.get(target.key);
+ if (outline !== undefined && outline.path !== null) {
+ // Path outlines do not render rotation handles.
+ return [];
+ }
+
const rotationDrag = target.selected
? (getLatestOutlineTargetByKey(target.key)?.rotationDrag ?? null)
: null;
diff --git a/packages/studio/src/components/composition-drop-preview.ts b/packages/studio/src/components/composition-drop-preview.ts
index ca51036702..ba085ec4a6 100644
--- a/packages/studio/src/components/composition-drop-preview.ts
+++ b/packages/studio/src/components/composition-drop-preview.ts
@@ -59,7 +59,7 @@ export const snapCompositionDropPosition = ({
key: 'composition-drop-preview',
dimensions: compositionDimensions,
uncroppedPoints: null,
- pathPoints: null,
+ path: null,
points: [
{x: left * scale, y: top * scale},
{x: right * scale, y: top * scale},
diff --git a/packages/studio/src/test/selected-outline-snap.test.ts b/packages/studio/src/test/selected-outline-snap.test.ts
index 59a0a562d5..e9a43add06 100644
--- a/packages/studio/src/test/selected-outline-snap.test.ts
+++ b/packages/studio/src/test/selected-outline-snap.test.ts
@@ -27,7 +27,7 @@ const makeOutline = ({
key: 'outline',
dimensions: {width, height},
uncroppedPoints: null,
- pathPoints: null,
+ path: null,
points: [
{x: left * scale, y: top * scale},
{x: right * scale, y: top * scale},
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index 6d7ec0d15d..b62575c695 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -3769,7 +3769,7 @@ test('Canvas outline rendering preserves unconstrained outline order', () => {
key,
dimensions: null,
uncroppedPoints: null,
- pathPoints: null,
+ path: null,
points: [
{x: 0, y: 0},
{x: 10, y: 0},
@@ -3817,7 +3817,7 @@ const makeTestOutline = ({
key,
dimensions: {width, height},
uncroppedPoints: null,
- pathPoints: null,
+ path: null,
points: [
{x: left, y: top},
{x: left + width, y: top},