Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Refactor Arc component to use responsive dimensions #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist

# Ignore the output video from Git but not videos you import into src/.
out
package-lock.json
16 changes: 10 additions & 6 deletions src/HelloWorld/Arc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ const getCircumferenceOfArc = (rx: number, ry: number) => {
return Math.PI * 2 * Math.sqrt((rx * rx + ry * ry) / 2);
};

const rx = 135;
const ry = 300;
const cx = 960;
const cy = 540;
const arcLength = getCircumferenceOfArc(rx, ry);
const strokeWidth = 30;
const rxRatio = 135 / 1920; // Ratio of rx to width
const ryRatio = 300 / 1080; // Ratio of ry to height
const strokeWidthRatio = 30 / 1920; // Ratio of strokeWidth to width

export const Arc: React.FC<{
progress: number;
Expand All @@ -21,6 +18,13 @@ export const Arc: React.FC<{
}> = ({progress, rotation, rotateProgress, color1, color2}) => {
const {width, height} = useVideoConfig();

const cx = width / 2; // Center X coordinate
const cy = height / 2; // Center Y coordinate
const rx = width * rxRatio;
const ry = height * ryRatio;
const strokeWidth = width * strokeWidthRatio;
const arcLength = getCircumferenceOfArc(rx, ry);

// Each svg Id must be unique to not conflict with each other
const [gradientId] = useState(() => String(random(null)));

Expand Down
4 changes: 2 additions & 2 deletions src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const RemotionRoot: React.FC = () => {
component={Logo}
durationInFrames={150}
fps={30}
width={1920}
height={1080}
width={3840}
height={2160}
schema={myCompSchema2}
defaultProps={{
logoColor1: '#91dAE2' as const,
Expand Down