Skip to content

🎥 Make videos programmatically with React

clamp

Jonny Burger56c5e64746a0
diff --git a/packages/shapes/src/utils/make-pie.ts b/packages/shapes/src/utils/make-pie.ts
index d35338d7af..aa9ab89f18 100644
--- a/packages/shapes/src/utils/make-pie.ts
+++ b/packages/shapes/src/utils/make-pie.ts
@@ -7,10 +7,12 @@ export type MakePieProps = {
};
export const makePie = ({fillAmount, radius}: MakePieProps) => {
+ const actualFillAmount = Math.min(Math.max(fillAmount, 0), 1);
+
const endAngleX =
- Math.cos(-fillAmount * Math.PI * 2 + Math.PI) * radius + radius;
+ Math.cos(-actualFillAmount * Math.PI * 2 + Math.PI) * radius + radius;
const endAngleY =
- Math.sin(-fillAmount * Math.PI * 2 + Math.PI) * radius + radius;
+ Math.sin(-actualFillAmount * Math.PI * 2 + Math.PI) * radius + radius;
const instructions: Instruction[] = [
{
@@ -25,10 +27,10 @@ export const makePie = ({fillAmount, radius}: MakePieProps) => {
xAxisRotation: 0,
largeArcFlag: false,
sweepFlag: false,
- x: fillAmount <= 0.5 ? endAngleX : radius * 2,
- y: fillAmount <= 0.5 ? endAngleY : radius,
+ x: actualFillAmount <= 0.5 ? endAngleX : radius * 2,
+ y: actualFillAmount <= 0.5 ? endAngleY : radius,
},
- fillAmount > 0.5
+ actualFillAmount > 0.5
? {
type: 'A',
rx: radius,
@@ -40,7 +42,7 @@ export const makePie = ({fillAmount, radius}: MakePieProps) => {
y: endAngleY,
}
: null,
- fillAmount > 0 && fillAmount < 1
+ actualFillAmount > 0 && actualFillAmount < 1
? {
type: 'L',
x: radius,