Skip to content

🎥 Make videos programmatically with React

fix bugs in normalizeInstructions

Jonny Burgerc77aaf652b1e
diff --git a/packages/paths/src/normalize-path.ts b/packages/paths/src/normalize-path.ts
index a59da5448f..183083445e 100644
--- a/packages/paths/src/normalize-path.ts
+++ b/packages/paths/src/normalize-path.ts
@@ -50,6 +50,8 @@ export const normalizeInstructions = (
instruction.type === 's' ||
instruction.type === 't'
) {
+ const currentX = x;
+ const currentY = y;
x += instruction.dx;
y += instruction.dy;
if (instruction.type === 'a') {
@@ -69,10 +71,10 @@ export const normalizeInstructions = (
if (instruction.type === 'c') {
normalized.push({
type: 'C',
- cp1x: instruction.cp1dx + x,
- cp1y: instruction.cp1dy + y,
- cp2x: instruction.cp2dx + x,
- cp2y: instruction.cp2dy + y,
+ cp1x: instruction.cp1dx + currentX,
+ cp1y: instruction.cp1dy + currentY,
+ cp2x: instruction.cp2dx + currentX,
+ cp2y: instruction.cp2dy + currentY,
x,
y,
});
@@ -100,8 +102,8 @@ export const normalizeInstructions = (
if (instruction.type === 'q') {
normalized.push({
type: 'Q',
- cpx: instruction.cpdx + x,
- cpy: instruction.cpdy + y,
+ cpx: instruction.cpdx + currentX,
+ cpy: instruction.cpdy + currentY,
x,
y,
});
@@ -111,8 +113,8 @@ export const normalizeInstructions = (
if (instruction.type === 's') {
normalized.push({
type: 'S',
- cpx: instruction.cpdx + x,
- cpy: instruction.cpdy + y,
+ cpx: instruction.cpdx + currentX,
+ cpy: instruction.cpdy + currentY,
x,
y,
});