pub struct PixelVec<T> {
    pub resolution: Vec2<usize>,
    pub pixels: Vec<T>,
}Expand description
Store all samples in a single array.
All samples will be converted to the type T.
This supports all the sample types, f16, f32, and u32.
The flattened vector contains all rows one after another. In each row, for each pixel, its red, green, blue, and then alpha samples are stored one after another.
Use PixelVec.compute_pixel_index(position)
to compute the flat index of a specific pixel.
Fields§
§resolution: Vec2<usize>The resolution of this layer.
pixels: Vec<T>The flattened vector contains all rows one after another. In each row, for each pixel, its red, green, blue, and then alpha samples are stored one after another.
Use Flattened::compute_pixel_index(image, position)
to compute the flat index of a specific pixel.
Implementations§
source§impl<Pixel> PixelVec<Pixel>
 
impl<Pixel> PixelVec<Pixel>
sourcepub fn constructor<Channels>(resolution: Vec2<usize>, _: &Channels) -> Selfwhere
    Pixel: Default + Clone,
 
pub fn constructor<Channels>(resolution: Vec2<usize>, _: &Channels) -> Selfwhere Pixel: Default + Clone,
Create a new flattened pixel storage, filled with default pixels.
Accepts a Channels parameter, which is not used, so that it can be passed as a function pointer instead of calling it.
sourcepub fn get_pixel(&self, position: Vec2<usize>) -> &Pixelwhere
    Pixel: Sync,
 
pub fn get_pixel(&self, position: Vec2<usize>) -> &Pixelwhere Pixel: Sync,
Examine a pixel of a PixelVec<T> image.
Can usually be used as a function reference instead of calling it directly.
sourcepub fn set_pixel(&mut self, position: Vec2<usize>, pixel: Pixel)
 
pub fn set_pixel(&mut self, position: Vec2<usize>, pixel: Pixel)
Update a pixel of a PixelVec<T> image.
Can usually be used as a function reference instead of calling it directly.
sourcepub fn new(resolution: impl Into<Vec2<usize>>, pixels: Vec<Pixel>) -> Self
 
pub fn new(resolution: impl Into<Vec2<usize>>, pixels: Vec<Pixel>) -> Self
Create a new flattened pixel storage, checking the length of the provided pixels vector.
sourcepub fn compute_pixel_index(&self, position: Vec2<usize>) -> usize
 
pub fn compute_pixel_index(&self, position: Vec2<usize>) -> usize
Compute the flat index of a specific pixel. Returns a range of either 3 or 4 samples.
The computed index can be used with PixelVec.samples[index].
Panics for invalid sample coordinates.