Skip to main content

fit_scale

Function fit_scale 

Source
pub fn fit_scale(half: [f32; 2], aspect: f32) -> f32
Expand description

The world scale that fits a figure of this half-extent inside the frame.

Aspect-aware, and it has to be (ADR-0037’s lesson in its own costume). The vertex shader divides world x by the target’s aspect and leaves y alone, so the horizontal budget is aspect world units and the vertical is 1. A single scale fitted at 16:9 leaves the dragon and the spiral — both about twice as wide as they are tall — hanging out of a portrait window. Taking the smaller of the two fits is what makes “inside the frame” true at every aspect rather than at one.

Rotation is a separate axis, and this does not cover it (ADR-0103). The box being fitted is axis-aligned, and project’s 2D branch rotates it by the spin phase afterwards — spin defaults to on — so what this guarantees is “inside the frame at neutral levers and zero rotation”. A rotated figure reaches hypot(hx, hy) on both axes at its worst angle, which for every shipped figure but the fern is outside the frame. zoom is the recourse, the same one the levers have.

The aspect comes from the render target, never from the trail grid: the grid is a resolution, not a shape (ADR-0037), and the present is a plain stretch, so the grid’s own aspect cancels out.