Skip to content

🎥 Make videos programmatically with React

shape corner radius

Jonny Burger38ec8d0e871f
diff --git a/packages/shapes/src/utils/join-points.ts b/packages/shapes/src/utils/join-points.ts
index 6d1db51fc5..e8f2f31025 100644
--- a/packages/shapes/src/utils/join-points.ts
+++ b/packages/shapes/src/utils/join-points.ts
@@ -22,7 +22,14 @@ export const joinPoints = (
{
edgeRoundness,
cornerRadius,
- }: {edgeRoundness: number | null; cornerRadius: number}
+ largeArcFlag,
+ sweepFlag,
+ }: {
+ edgeRoundness: number | null;
+ cornerRadius: number;
+ largeArcFlag: boolean;
+ sweepFlag: boolean;
+ }
) => {
return points
.map(([x, y], i): Instruction | Instruction[] => {
@@ -57,6 +64,7 @@ export const joinPoints = (
if (edgeRoundness === null) {
const prevVectorMinusRadius = shortenVector(prevVector, cornerRadius);
+ const prevVectorLenght = scaleVectorToLength(prevVector, cornerRadius);
const nextVectorMinusRadius = scaleVectorToLength(
nextVector,
cornerRadius
@@ -69,13 +77,14 @@ export const joinPoints = (
y: prevPoint[1] + prevVectorMinusRadius[1],
},
{
- type: 'C',
- cp1x: x,
- cp1y: y,
- cp2x: x,
- cp2y: y,
- x: x + nextVectorMinusRadius[0],
- y: y + nextVectorMinusRadius[1],
+ type: 'a',
+ rx: cornerRadius,
+ ry: cornerRadius,
+ xAxisRotation: 0,
+ x: prevVectorLenght[0] + nextVectorMinusRadius[0],
+ y: prevVectorLenght[1] + nextVectorMinusRadius[1],
+ largeArcFlag,
+ sweepFlag,
},
];
}
diff --git a/packages/shapes/src/utils/make-rect.ts b/packages/shapes/src/utils/make-rect.ts
index 84cf5d7d9f..6e947d1d8c 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}
+ {edgeRoundness, cornerRadius, largeArcFlag: false, sweepFlag: true}
);
const path = serializeInstructions(instructions);
diff --git a/packages/shapes/src/utils/make-triangle.ts b/packages/shapes/src/utils/make-triangle.ts
index b59cc54bbd..06184adb5d 100644
--- a/packages/shapes/src/utils/make-triangle.ts
+++ b/packages/shapes/src/utils/make-triangle.ts
@@ -66,6 +66,8 @@ export const makeTriangle = ({
const instructions = joinPoints(points[direction], {
edgeRoundness,
cornerRadius,
+ largeArcFlag: false,
+ sweepFlag: false,
});
const path = serializeInstructions(instructions);