Skip to main content

lerp_packed_params

Function lerp_packed_params 

Source
pub fn lerp_packed_params(
    a: &[Vec4],
    b: &[Vec4],
    t: f32,
    layout: &[ParamSlot],
) -> Vec<Vec4>
Expand description

Interpolate two packed param arrays of the same layout, slot-by-slot: the layout (not the raw components) decides how each param blends.

  • ValueKind::Scalar / ValueKind::Length / ValueKind::Color slots lerp component-wise in the packed space. For colors that is linear-space interpolation — filter color params are packed linear RGBA (see FilterColor), shader-ready; converting to sRGB to interpolate would both diverge from what the shader sees and hand the GPU values it doesn’t consume. (The style layer’s [f32; 4] crate::animations::Lerp doc says sRGB component-wise — that applies to style colors, which live in sRGB; do not conflate the two spaces.)
  • ValueKind::Angle slots take the shortest arc via lerp_angle.

Components no slot covers (no-straddle padding — zero by the packing contract) copy from b, so padding is stable rather than blended; the choice is unobservable for contract-abiding packers. t == 0.0 / t == 1.0 return a / b bit-exactly (whole array, padding included); other t use the plain a + (b - a) * t form, so out-of-range t extrapolates.

The caller guarantees a/b came from the same layout; a length mismatch is a bug upstream (debug_asserted) and defensively returns b.to_vec() in release. Slot indices out of the arrays’ bounds are skipped, like the resolver’s physical-px rewrite.