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
impl SampleMap
Sourcepub fn rebuild(&mut self, src: Size, dst: Size)
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).
Sourcepub fn magnification(&self) -> f32
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.
Sourcepub fn sample_cubic(&self, src: &Grid<f32>, x: i32, y: i32) -> f32
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.
Sourcepub fn row_cubic<'a>(&'a self, src: &'a Grid<f32>, y: i32) -> CubicRow<'a>
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).
Sourcepub fn sample(&self, src: &Grid<f32>, x: i32, y: i32) -> f32
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.
Sourcepub fn row<'a>(&'a self, src: &'a Grid<f32>, y: i32) -> MapRow<'a>
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.