Skip to main content

compute_stretch_ratio

Function compute_stretch_ratio 

Source
fn compute_stretch_ratio(
    stretch_size: LayoutSize,
    prim_size: LayoutSize,
) -> LayoutSize
Expand description

Encode a gradient’s per-tile stretch as a fraction of its prim_size. Per-axis: ratio = stretch_size / prim_size, clamped to [0, 1] (the upper bound matches the old stretch_size.min(prim_size) clamp on the radial and conic templates and avoids over-allocating render-task pixels).

If prim_size isn’t finite-positive on both axes we fall back to a uniform (1.0, 1.0) ratio, not per-axis. A per-axis fallback can mix a sentinel 1.0 (NaN axis) with a real ratio (finite axis), which at prep produces a partially-NaN stretch_size — that breaks downstream invariants like image_tiling::repetitions’s stride > 0 assertion (NaN width passes the finite-height needs_repetition check and reaches the assert before the NaN-aware intersection short-circuit fires).