Skip to content

@remotion/paths: Cut the closing Z command in cutPath() - #12921

Merged
JonnyBurger merged 1 commit into
remotion-dev:mainfrom
b84330808:paths-cut-closing-z
Nov 4, 2026
Merged

JonnyBurger merged 1 commit into
remotion-dev:mainfrom
b84330808:paths-cut-closing-z

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

cutPath() returned the whole closed path when the cut length fell on the closing line. cutInstruction() returned Z uncut (there was a TODO for it), so everything up to the end of the shape came back:

cutPath('M 0 0 L 100 0 L 100 100 Z', 250);
// before: 'M 0 0 L 100 0 L 100 100 Z' (length 341.4)
// after:  'M 0 0 L 100 0 L 100 100 L 64.64… 64.64…' (length 250)

Z draws a straight line back to the start of the subpath, so cutPath() now cuts it as an L to that point. Cuts past the Z, and paths with more subpaths after it, stay the same.

Added a test that checks the length of the result and that it ends at getPointAtLength(path, 250).

I used Claude Code to write this change.

`cutPath()` returned the whole closed path when the cut fell on the
closing line, because `cutInstruction()` returned `Z` uncut. Cut it
as a line back to the start of the subpath.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bugs Ready Ready Preview Nov 3, 2026 4:12pm UTC
remotion Ready Ready Preview Nov 3, 2026 4:12pm UTC

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — initial review of the two-file diff.

  • cutPath() closing Z handling — packages/paths/src/cut-path.ts:23-32 substitutes the Z instruction with an L to the subpath start before calling cutInstruction(), so a cut that lands on the closing line returns a truncated path instead of the whole shape.
  • Test coverage — packages/paths/src/test/cut-path.test.ts:59-73 adds a test asserting both the length of the result and that its endpoint matches getPointAtLength(path, 250).

I verified the fix against the existing suite (bun test in packages/paths, 110 pass) and manually exercised edge cases: a cut exactly at total length still preserves the trailing Z, cuts landing on a non-final subpath's Z interpolate from the correct subpath start, and the emitted L endpoint matches getPointAtLength(). The Z-to-L substitution is sound because segment.startPoint is that subpath's M point in conductAnalysis().

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@JonnyBurger
JonnyBurger merged commit 13261b6 into remotion-dev:main Nov 4, 2026
18 of 20 checks passed
@JonnyBurger

Copy link
Copy Markdown
Member

Thanks!

This branch was successfully deployed

2 active deployments
Preview – remotion — 8a53970a Deployed Nov 3, 2026 by vercel[bot]
Preview – bugs — 8a53970a Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants