Skip to content

🎥 Make videos programmatically with React

round corner strategy

Jonny Burger343a56b345d6
diff --git a/packages/shapes/src/utils/join-points.ts b/packages/shapes/src/utils/join-points.ts
index 80275e2860..3ee8563f82 100644
--- a/packages/shapes/src/utils/join-points.ts
+++ b/packages/shapes/src/utils/join-points.ts
@@ -22,9 +22,11 @@ export const joinPoints = (
{
edgeRoundness,
cornerRadius,
+ roundCornerStrategy,
}: {
edgeRoundness: number | null;
cornerRadius: number;
+ roundCornerStrategy: 'arc' | 'bezier';
}
) => {
return points
@@ -83,15 +85,28 @@ export const joinPoints = (
x: firstDraw[0],
y: firstDraw[1],
},
- {
- type: 'C',
- x: firstDraw[0] + prevVectorLenght[0] + nextVectorMinusRadius[0],
- y: firstDraw[1] + prevVectorLenght[1] + nextVectorMinusRadius[1],
- cp1x: x,
- cp1y: y,
- cp2x: x,
- cp2y: y,
- },
+ roundCornerStrategy === 'arc'
+ ? {
+ type: 'a',
+ rx: cornerRadius,
+ ry: cornerRadius,
+ xAxisRotation: 0,
+ x: prevVectorLenght[0] + nextVectorMinusRadius[0],
+ y: prevVectorLenght[1] + nextVectorMinusRadius[1],
+ largeArcFlag: false,
+ sweepFlag: true,
+ }
+ : {
+ type: 'C',
+ x:
+ firstDraw[0] + prevVectorLenght[0] + nextVectorMinusRadius[0],
+ y:
+ firstDraw[1] + prevVectorLenght[1] + nextVectorMinusRadius[1],
+ cp1x: x,
+ cp1y: y,
+ cp2x: x,
+ cp2y: y,
+ },
];
}
diff --git a/packages/shapes/src/utils/make-rect.ts b/packages/shapes/src/utils/make-rect.ts
index 6e947d1d8c..12b8247f8b 100644
--- a/packages/shapes/src/utils/make-rect.ts
+++ b/packages/shapes/src/utils/make-rect.ts
@@ -24,7 +24,7 @@ export const makeRect = ({
[0, height],
[0, 0],
],
- {edgeRoundness, cornerRadius, largeArcFlag: false, sweepFlag: true}
+ {edgeRoundness, cornerRadius, roundCornerStrategy: 'arc'}
);
const path = serializeInstructions(instructions);
diff --git a/packages/shapes/src/utils/make-triangle.ts b/packages/shapes/src/utils/make-triangle.ts
index b59cc54bbd..3d9fee18ec 100644
--- a/packages/shapes/src/utils/make-triangle.ts
+++ b/packages/shapes/src/utils/make-triangle.ts
@@ -66,6 +66,7 @@ export const makeTriangle = ({
const instructions = joinPoints(points[direction], {
edgeRoundness,
cornerRadius,
+ roundCornerStrategy: 'bezier',
});
const path = serializeInstructions(instructions);