mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-30 19:58:50 +00:00
13 lines
496 B
TypeScript
13 lines
496 B
TypeScript
import { polygonArea } from './logic';
|
|
|
|
/** View-safe area helpers kept separate from the lazy resize implementation. */
|
|
export function areaM2(poly: number[][], gridPitch: number, cellCm: number): number {
|
|
const cmPerUnit = cellCm / gridPitch;
|
|
return (polygonArea(poly) * cmPerUnit * cmPerUnit) / 1e4;
|
|
}
|
|
|
|
export function formatArea(m2: number, imperial: boolean): string {
|
|
if (imperial) return `${Math.round(m2 * 10.7639)} ft²`;
|
|
return `${(Math.round(m2 * 10) / 10).toFixed(1)} m²`;
|
|
}
|