Repository navigation
@remotion/paths: Fix geometry of chained T commands after a non-quadratic command - #12821
Merged
JonnyBurger merged 1 commit intoOct 30, 2026
Merged
Conversation
…uadratic command Per the SVG spec, a `T`/`t` that does not follow a quadratic command uses the current point as its control point, and the next `T` reflects that. - `getLength()` and the other `construct()`-based helpers reflected a stale control point (from an earlier `Q`, or the origin) instead, so the result also changed when the path was translated. - `reduceInstructions()` left the tracked control point `null` after `H`/`L`/`V`/`A`/`Z`/`M`, and reflected the cubic's second control point after `C`/`S`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018KWRbA1vtGSbDKWjrU4XXq
Contributor
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
construct.ts— after processing aT/t,prev_pointis now set to the current point when the predecessor is notQ/q/T/t, instead of reflecting a stale control point. This matches the spec and makes chainedTlengths translation-invariant.iterate.ts—Tsegment state now only reflects the tracked control point when the previous segment is actuallyQorT; otherwise it sets the control point to the current point. Previously aTfollowingC/Sreflectedcp2x/cpx, corrupting the nextT.get-length.test.ts— new test asserting aTchain afterHequals the explicitQequivalent, including a translated copy.reduce-instructions.test.ts— new test assertingTchains afterHand afterCreduce to the same instructions as the explicitQequivalents.
I verified the reflection logic in both code paths against the SVG spec by tracing H 10 T 20 10 T 30 0 and C ... T 20 10 T 30 0, and ran the full @remotion/paths suite: 104 pass, 0 fail.
deepseek-v4.1-flash | 𝕏
Member
|
Thanks! |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Per the SVG spec, a
T/tthat does not follow aQ/q/T/tuses the current point as its control point, and the nextTreflects that control point. Both code paths in@remotion/pathsgot the secondTwrong:construct()(used bygetLength(),getPointAtLength(),getTangentAtLength(),getInstructionIndexAtLength(),evolvePath()) reflected a stale control point instead: the one from an earlierQ, or[0, 0]. Because that point is absolute, the result also changed when the path was translated.iterateOverSegments()(used byreduceInstructions(), and through itgetBoundingBox(),cutPath(),reversePath(),scalePath(),warpPath(),interpolatePath()) left the tracked control pointnullafterH/L/V/A/Z/M, which was then read as0. AfterC/S, it reflected the cubic's second control point.getTotalLength()getLength()beforeM 0 0 H 10 T 20 10 T 30 0translatePath(path, 100, 100)M 0 0 C 0 10 10 10 10 0 T 20 10 T 30 0M 0 0 Q 5 5 10 0 L 20 0 T 30 10 T 40 0I also compared 2000 random paths mixing every command against Chromium's
getTotalLength(). Before:getLength()disagreed on 300 andgetLength(serializeInstructions(reduceInstructions(...)))on 296. After: 0 and 0.The added tests compare each
Tchain with the equivalent explicitQpath.I used Claude Code to write this change.