Skip to content

🎥 Make videos programmatically with React

rename fillAmount to progress

Jonny Burgerc5338ac083fc
diff --git a/packages/docs/components/demos/Pie.tsx b/packages/docs/components/demos/Pie.tsx
index cbcf9adfeb..daac0b0f5a 100644
--- a/packages/docs/components/demos/Pie.tsx
+++ b/packages/docs/components/demos/Pie.tsx
@@ -5,13 +5,13 @@ import { AbsoluteFill } from "remotion";
export const PieDemo: React.FC<{
radius: number;
darkMode: boolean;
- fillAmount: number;
+ progress: number;
closePath: boolean;
showStrokeInsteadPreviewOnly: boolean;
}> = ({
radius,
darkMode,
- fillAmount,
+ progress,
closePath,
showStrokeInsteadPreviewOnly,
}) => {
@@ -23,7 +23,7 @@ export const PieDemo: React.FC<{
}}
>
<Pie
- fillAmount={fillAmount}
+ progress={progress}
fill={
showStrokeInsteadPreviewOnly
? "transparent"
diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.ts
index 4511fcb20d..d0730d62ff 100644
--- a/packages/docs/components/demos/types.ts
+++ b/packages/docs/components/demos/types.ts
@@ -190,7 +190,7 @@ export const pieDemo: DemoType = {
min: 0,
max: 1,
type: "numeric",
- name: "fillAmount",
+ name: "progress",
optional: "no",
},
{
diff --git a/packages/docs/components/shapes/shapes-info.tsx b/packages/docs/components/shapes/shapes-info.tsx
index 9085763788..4fad35ffd8 100644
--- a/packages/docs/components/shapes/shapes-info.tsx
+++ b/packages/docs/components/shapes/shapes-info.tsx
@@ -63,7 +63,7 @@ export const shapeComponents: ShapeComponent[] = [
description: "The radius of the circle.",
},
{
- name: "fillAmount",
+ name: "progress",
type: "number",
description:
"The percentage of the circle that is filled. 0 means fully empty, 1 means fully filled.",
diff --git a/packages/docs/docs/shapes/make-pie.md b/packages/docs/docs/shapes/make-pie.md
index b4b7fd934d..6709f296a9 100644
--- a/packages/docs/docs/shapes/make-pie.md
+++ b/packages/docs/docs/shapes/make-pie.md
@@ -16,7 +16,7 @@ import { makePie } from "@remotion/shapes";
const { path, width, height, transformOrigin } = makePie({
radius: 50,
- fillAmount: 0.5,
+ progress: 0.5,
});
// TOOD: Wrong paths
diff --git a/packages/docs/docs/shapes/pie.md b/packages/docs/docs/shapes/pie.md
index 054cd18bf0..af6e142774 100644
--- a/packages/docs/docs/shapes/pie.md
+++ b/packages/docs/docs/shapes/pie.md
@@ -30,7 +30,7 @@ export const MyComposition = () => {
>
<Pie
radius={100}
- fillAmount={0.5}
+ progress={0.5}
fill="green"
stroke="red"
strokeWidth={1}
diff --git a/packages/shapes/src/components/pie.tsx b/packages/shapes/src/components/pie.tsx
index 66ead81167..bcd642590c 100644
--- a/packages/shapes/src/components/pie.tsx
+++ b/packages/shapes/src/components/pie.tsx
@@ -8,9 +8,9 @@ export type PieProps = MakePieProps & AllShapesProps;
export const Pie: React.FC<PieProps> = ({
radius,
- fillAmount,
+ progress,
closePath,
...props
}) => {
- return <RenderSvg {...makePie({radius, fillAmount, closePath})} {...props} />;
+ return <RenderSvg {...makePie({radius, progress, closePath})} {...props} />;
};
diff --git a/packages/shapes/src/utils/make-pie.ts b/packages/shapes/src/utils/make-pie.ts
index 7fc5c09180..6d4d5a7828 100644
--- a/packages/shapes/src/utils/make-pie.ts
+++ b/packages/shapes/src/utils/make-pie.ts
@@ -3,21 +3,17 @@ import {serializeInstructions} from './instructions';
export type MakePieProps = {
radius: number;
- fillAmount: number;
+ progress: number;
closePath?: boolean;
};
-export const makePie = ({
- fillAmount,
- radius,
- closePath = true,
-}: MakePieProps) => {
- const actualFillAmount = Math.min(Math.max(fillAmount, 0), 1);
+export const makePie = ({progress, radius, closePath = true}: MakePieProps) => {
+ const actualProgress = Math.min(Math.max(progress, 0), 1);
const endAngleX =
- Math.cos(actualFillAmount * Math.PI * 2 + Math.PI * 1.5) * radius + radius;
+ Math.cos(actualProgress * Math.PI * 2 + Math.PI * 1.5) * radius + radius;
const endAngleY =
- Math.sin(actualFillAmount * Math.PI * 2 + Math.PI * 1.5) * radius + radius;
+ Math.sin(actualProgress * Math.PI * 2 + Math.PI * 1.5) * radius + radius;
const start = {x: radius, y: 0};
const end = {x: endAngleX, y: endAngleY};
@@ -34,10 +30,10 @@ export const makePie = ({
xAxisRotation: 0,
largeArcFlag: false,
sweepFlag: true,
- x: actualFillAmount <= 0.5 ? endAngleX : radius,
- y: actualFillAmount <= 0.5 ? endAngleY : radius * 2,
+ x: actualProgress <= 0.5 ? endAngleX : radius,
+ y: actualProgress <= 0.5 ? endAngleY : radius * 2,
},
- actualFillAmount > 0.5
+ actualProgress > 0.5
? {
type: 'A',
rx: radius,
@@ -48,7 +44,7 @@ export const makePie = ({
...end,
}
: null,
- actualFillAmount > 0 && actualFillAmount < 1 && closePath
+ actualProgress > 0 && actualProgress < 1 && closePath
? {
type: 'L',
x: radius,