diff options
Diffstat (limited to 'apps/web/src/utils/geometry.ts')
| -rw-r--r-- | apps/web/src/utils/geometry.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/web/src/utils/geometry.ts b/apps/web/src/utils/geometry.ts new file mode 100644 index 00000000..23fc4f46 --- /dev/null +++ b/apps/web/src/utils/geometry.ts @@ -0,0 +1,13 @@ +export function dimensionToAspectRatio({ + width, + height, +}: { + width: number; + height: number; +}): string { + const gcd = (a: number, b: number): number => (b === 0 ? a : gcd(b, a % b)); + const divisor = gcd(width, height); + const aspectWidth = width / divisor; + const aspectHeight = height / divisor; + return `${aspectWidth}:${aspectHeight}`; +} |
