Files
feuerwerk/src/core/properties/camera.ts
T
rootandClaude Opus 5 4d84231b9f Trim needless comments and fix the picker width
Remove comments that only restate the code, keeping the section banners
and the notes that carry a reason, a measured fact or an external
contract.

ButtonOptions.width claimed to be a fixed width but only set minWidth,
so the Graph and Texture pickers grew with the name they showed. It is
now what it promises, with a separate minWidth for the buttons that have
two forms. Narrow buttons shrink their padding, otherwise a 24px icon
button had 8px left for its glyph and truncate dropped it entirely.

__gm.labelsDropped() guards that class: the overflow guard only saw text
that was too wide, never a label truncated to nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 15:52:05 +02:00

33 lines
1.0 KiB
TypeScript

import type { PropertyBag } from '../model/Properties';
import { defaultsFor } from './PropertySchema';
const DEFAULTS = defaultsFor('camera');
/** Axis-aligned rectangle in world units. */
export interface WorldRect {
left: number;
top: number;
right: number;
bottom: number;
}
/**
* The world region a camera shows: its view size divided by its zoom. Drawn as a frame in edit mode,
* and the only region rendered in play mode.
*/
export function cameraFrame(props: PropertyBag): { w: number; h: number } {
const zoom = Math.max(0.01, Number(props.zoom ?? DEFAULTS.zoom));
return {
w: Number(props.width ?? DEFAULTS.width) / zoom,
h: Number(props.height ?? DEFAULTS.height) / zoom,
};
}
export function rectAround(cx: number, cy: number, w: number, h: number): WorldRect {
return { left: cx - w / 2, top: cy - h / 2, right: cx + w / 2, bottom: cy + h / 2 };
}
export function rectsIntersect(a: WorldRect, b: WorldRect): boolean {
return a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;
}