units.ts

src/scene/units.ts
/** Display unit systems for the UI (independent of the scene's stored units). */
export type UnitSystem = 'imperial' | 'inches';
export function formatImperial(inches: number, opts: { precision?: 'inch' | 'eighth' } = {}): string {
const sign = inches < 0 ? '-' : '';
const abs = Math.abs(inches);
const feet = Math.floor(abs / 12);
const remIn = abs - feet * 12;
if (opts.precision === 'eighth') {
const eighths = Math.round(remIn * 8);
const whole = Math.floor(eighths / 8);
const frac = eighths % 8;
const fracStr =
frac === 0
? ''
: frac === 4
? ' 1/2'
: frac === 2
? ' 1/4'

Showing the first 20 lines.

Get full code

Support

Talk to the developers of this project to learn more

We have been building professional websites for big clients for over 15 years. Gallop templates and blocks is our best foundation for SEO websites and web apps.

© 2026 Web Plant Media, LLC