Skip to content

🎥 Make videos programmatically with React

`@remotion/paths`: Fix `translatePath()` for paths starting with `m`

Jonny Burger8821f70daf1c
diff --git a/packages/paths/src/translate-path.ts b/packages/paths/src/translate-path.ts
index 0c9daf1f2d..f2f8249cc4 100644
--- a/packages/paths/src/translate-path.ts
+++ b/packages/paths/src/translate-path.ts
@@ -8,7 +8,16 @@ export const translateSegments = (
x: number,
y: number,
) => {
- return segments.map((segment): Instruction => {
+ return segments.map((segment, index): Instruction => {
+ // An initial relative moveto is relative to the origin.
+ if (segment.type === 'm' && index === 0) {
+ return {
+ type: 'm',
+ dx: segment.dx + x,
+ dy: segment.dy + y,
+ };
+ }
+
// Shift coords only for commands with absolute values
if (
segment.type === 'a' ||