pub struct InterpLut<const N: usize> { /* private fields */ }Implementations§
Source§impl<const N: usize> InterpLut<N>
impl<const N: usize> InterpLut<N>
Sourcepub const fn from_knots(knots: [Q0_16; N], max_err_lsb: u16) -> Self
pub const fn from_knots(knots: [Q0_16; N], max_err_lsb: u16) -> Self
Construct from a flash-resident knot table.
max_err_lsb is the bake-supplied bound (may be 0 until tables are
generated). N must be 17, 33, 65, or 257.
Sourcepub const fn max_err_lsb(&self) -> u16
pub const fn max_err_lsb(&self) -> u16
Bake-supplied maximum absolute error in UQ0.16 LSBs.
Sourcepub const fn lookup(&self, x: Q0_16) -> Q0_16
pub const fn lookup(&self, x: Q0_16) -> Q0_16
Interpolate x between knots. Endpoints return the tabulated values.
N is 17..=257 (enforced by Self::from_knots), so segs and
pos stay far inside u32 — no 64-bit multiply, and
the arith reciprocal helper means no divide at all.
There is no x == 65535 early return. Clamping the segment index to
N - 2 makes the top knot fall out of the general path: at
x == 65535 the clamped remainder is exactly 65535, so the blend
returns knots[N - 1] unchanged. One clamp replaces a branch, a
second table read, and a separate remainder division.
Sourcepub const fn encode<S: ColorSpace>(
&self,
color: Color<S, Linear>,
) -> Color<S, Encoded>
pub const fn encode<S: ColorSpace>( &self, color: Color<S, Linear>, ) -> Color<S, Encoded>
Per-channel encode: Linear<S> → Encoded<S>.
Sourcepub const fn decode<S: ColorSpace>(
&self,
color: Color<S, Encoded>,
) -> Color<S, Linear>
pub const fn decode<S: ColorSpace>( &self, color: Color<S, Encoded>, ) -> Color<S, Linear>
Per-channel decode: Encoded<S> → Linear<S>.
Sourcepub fn lookup_f32(&self, x: f32) -> f32
pub fn lookup_f32(&self, x: f32) -> f32
Piecewise-linear lookup with unit f32 x, clamped to 0.0..=1.0.
Knots are UQ0.16 values converted to unit f32.
Additive: does not change Self::lookup.
Sourcepub fn encode_f32<S: ColorSpace>(
&self,
color: ColorF32<S, Linear>,
) -> ColorF32<S, Encoded>
pub fn encode_f32<S: ColorSpace>( &self, color: ColorF32<S, Linear>, ) -> ColorF32<S, Encoded>
Per-channel f32 encode: Linear<S> → Encoded<S>.
Sourcepub fn decode_f32<S: ColorSpace>(
&self,
color: ColorF32<S, Encoded>,
) -> ColorF32<S, Linear>
pub fn decode_f32<S: ColorSpace>( &self, color: ColorF32<S, Encoded>, ) -> ColorF32<S, Linear>
Per-channel f32 decode: Encoded<S> → Linear<S>.