Skip to main content

InterpLut

Struct InterpLut 

Source
pub struct InterpLut<const N: usize> { /* private fields */ }
Expand description

Piecewise-linear Q0_16Q0_16 table with N knots.

Implementations§

Source§

impl<const N: usize> InterpLut<N>

Source

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.

Source

pub const fn max_err_lsb(&self) -> u16

Bake-supplied maximum absolute error in UQ0.16 LSBs.

Source

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.

Source

pub const fn encode<S: ColorSpace>( &self, color: Color<S, Linear>, ) -> Color<S, Encoded>

Per-channel encode: Linear<S>Encoded<S>.

Source

pub const fn decode<S: ColorSpace>( &self, color: Color<S, Encoded>, ) -> Color<S, Linear>

Per-channel decode: Encoded<S>Linear<S>.

Source

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.

Source

pub fn encode_f32<S: ColorSpace>( &self, color: ColorF32<S, Linear>, ) -> ColorF32<S, Encoded>

Per-channel f32 encode: Linear<S>Encoded<S>.

Source

pub fn decode_f32<S: ColorSpace>( &self, color: ColorF32<S, Encoded>, ) -> ColorF32<S, Linear>

Per-channel f32 decode: Encoded<S>Linear<S>.

Trait Implementations§

Source§

impl<const N: usize> Clone for InterpLut<N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Copy for InterpLut<N>

Auto Trait Implementations§

§

impl<const N: usize> Freeze for InterpLut<N>
where [Q0_16; N]: Freeze,

§

impl<const N: usize> RefUnwindSafe for InterpLut<N>
where [Q0_16; N]: RefUnwindSafe,

§

impl<const N: usize> Send for InterpLut<N>
where [Q0_16; N]: Send,

§

impl<const N: usize> Sync for InterpLut<N>
where [Q0_16; N]: Sync,

§

impl<const N: usize> Unpin for InterpLut<N>
where [Q0_16; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for InterpLut<N>
where [Q0_16; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for InterpLut<N>
where [Q0_16; N]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.