Skip to main content

quantize_raster_scale

Function quantize_raster_scale 

Source
pub fn quantize_raster_scale(scale: f32) -> f32
Expand description

Quantize an accumulated densification scale onto a geometric ladder of 1.25ⁿ steps, n ∈ [0, 6] (so the value lands in [1.0, ~3.81]), for glyph raster densification under zoom / external scale transforms.

The ladder bounds the number of distinct atlas entries a continuous zoom gesture can create (7 buckets). The bucket value is derived from an integer index, so the same input always yields the bit-identical f32 — cache keys stay stable across frames — and the function is idempotent (a bucket value maps to itself). Between buckets the residual GPU scaling is at most ~12%, invisible under the glyph atlas’s linear filtering. Scales below 1 clamp to 1: zoomed-out text relies on linear minification rather than rasterizing below logical size.

Kept in lockstep with bastyde_canvas::quantize_raster_scale (scene transform densification uses the same ladder).