Skip to main content

SampleMap

Struct SampleMap 

Source
pub struct SampleMap { /* private fields */ }
Expand description

Precomputed per-axis sampling tables from a simulation lattice onto a display region (CORE-R52, ADR-0012): the per-cell work of resample_bilinear / resample_nearest without the float divisions, and without a destination grid, so a scene can sample its capped lattice straight into Pixels or Dots.

Built in resize with rebuild; the tables allocate only when they grow. The Default map is empty: sample gives 0 and nearest (0, 0).

Implementations§

Source§

impl SampleMap

Source

pub fn rebuild(&mut self, src: Size, dst: Size)

Tables for sampling a src grid at every cell of a dst region, with the cell-centre, edge-clamp convention of resample_bilinear (CORE-R52).

Source

pub fn magnification(&self) -> f32

How many destination cells span one source cell, along the more magnified axis (0 for the empty map). GEN-R17: bilinear up to 2, sample_cubic above it.

Source

pub fn sample_cubic(&self, src: &Grid<f32>, x: i32, y: i32) -> f32

Separable Catmull-Rom value of src at destination cell (x, y) (clamped onto the region), CORE-R102: 4 × 4 taps with weights from the rebuild tables (no transcendental maths), clamped to the range of the four central source values so it never overshoots into a new colour. Exact at source centres for equal sizes; a wrong-size source or the empty map gives 0, as sample.

Source

pub fn row_cubic<'a>(&'a self, src: &'a Grid<f32>, y: i32) -> CubicRow<'a>

Row y (clamped) of sample_cubic with its four source rows and weights looked up once (CORE-R102, as row).

Source

pub fn sample(&self, src: &Grid<f32>, x: i32, y: i32) -> f32

Bilinear value of src at destination cell (x, y) (clamped onto the region), bit-identical to resample_bilinear’s output for that cell (CORE-R52).

src must have the size passed to rebuild; any other size (a caller bug) and the empty map give 0.

Source

pub fn row<'a>(&'a self, src: &'a Grid<f32>, y: i32) -> MapRow<'a>

Row y of the destination region (clamped onto it) as a MapRow: its two source rows and weight looked up once, so sampling a whole row costs one x-tap per cell (CORE-R104). row(src, y).at(x) is bit-identical to sample(src, x, y), including 0 for the empty map or a source of another size.

Source

pub fn nearest(&self, x: i32, y: i32) -> (i32, i32)

The source cell nearest to destination cell (x, y) (clamped onto the region), the one resample_nearest copies; (0, 0) for the empty map (CORE-R52).

Trait Implementations§

Source§

impl Clone for SampleMap

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 Debug for SampleMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SampleMap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V