Skip to main content

Matrix

Struct Matrix 

Source
pub struct Matrix<P> { /* private fields */ }
Expand description

A matrix of packed texels (channel groups).

The underlying buffer may have more data allocated than this region and cause the overhead to be reused when resizing the image. All ways to construct this already check that all pixels within the resulting image can be addressed via an index.

Implementations§

Source§

impl<P> Matrix<P>

Source

pub fn from_width_height( pixel: Texel<P>, width: usize, height: usize, ) -> Option<Self>

Source

pub fn width_and_height(width: usize, height: usize) -> Option<Self>
where P: AsTexel,

Source

pub const fn empty(pixel: Texel<P>) -> Self

Source

pub fn into_matrix_bytes(self) -> MatrixBytes

Source

pub fn byte_len(self) -> usize

Get the required bytes for this layout.

Source

pub fn len(self) -> usize

The number of pixels in this layout

Source

pub fn width(self) -> usize

Source

pub fn height(self) -> usize

Source

pub fn pixel(self) -> Texel<P>

Source

pub fn transmute<Q: AsTexel>(self) -> Matrix<Q>

Reinterpret to another, same size pixel type.

See transmute_to for details.

Source

pub fn transmute_to<Q>(self, pixel: Texel<Q>) -> Matrix<Q>

Reinterpret to another, same size pixel type.

§Panics

Like std::mem::transmute, the size of the two types need to be equal. This ensures that all indices are valid in both directions.

Source

pub fn map<Q: AsTexel>(self) -> Option<Matrix<Q>>

Utility method to change the pixel type without changing the dimensions.

Source

pub fn map_to<Q>(self, pixel: Texel<Q>) -> Option<Matrix<Q>>

Utility method to change the pixel type without changing the dimensions.

Source§

impl<P> Matrix<P>

Source

pub fn with_matrix(pixel: Texel<P>, matrix: MatrixBytes) -> Option<Self>

Trait Implementations§

Source§

impl<P> Clone for Matrix<P>

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<P> Copy for Matrix<P>

Source§

impl<P> Debug for Matrix<P>

Source§

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

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

impl<P: AsTexel> Default for Matrix<P>

Source§

fn default() -> Self

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

impl<P> Eq for Matrix<P>

Source§

impl<P> From<Matrix<P>> for MatrixBytes

Source§

fn from(mat: Matrix<P>) -> Self

Converts to this type from the input type.
Source§

impl<P> From<Matrix<P>> for Bytes

Source§

fn from(layout: Matrix<P>) -> Self

Converts to this type from the input type.
Source§

impl<P> Layout for Matrix<P>

Source§

fn byte_len(&self) -> usize

Source§

impl<P> MatrixLayout for Matrix<P>

Source§

fn matrix(&self) -> MatrixBytes

The valid matrix specification of this layout. Read more
Source§

impl<P> PartialEq for Matrix<P>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P> PartialOrd for Matrix<P>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<P> Raster<P> for Matrix<P>

Note: on 64-bit targets only the first u32::MAX dimensions appear accessible.

Source§

fn dimensions(&self) -> Coord

Source§

fn get(from: ImageRef<'_, &Self>, Coord: Coord) -> Option<P>

Source§

impl<P> RasterMut<P> for Matrix<P>

Source§

fn put(into: ImageMut<'_, &mut Self>, Coord: Coord, val: P)

Source§

fn shade(image: ImageMut<'_, &mut Self>, f: impl FnMut(u32, u32, &mut Pixel))

Evaluate a function on each texel of the raster image.
Source§

impl<P> SliceLayout for Matrix<P>

Source§

type Sample = P

The sample type itself.
Source§

fn sample(&self) -> Texel<P>

Get the sample description.
Source§

fn len(&self) -> usize

The number of samples. Read more
Source§

fn as_index(&self) -> TexelRange<Self::Sample>

Source§

impl<P: AsTexel> StridedLayout for Matrix<P>

Source§

fn strided(&self) -> StridedBytes

The valid strided specification of this layout. Read more
Source§

impl<P> Take for Matrix<P>

Source§

fn take(&mut self) -> Self

Auto Trait Implementations§

§

impl<P> Freeze for Matrix<P>

§

impl<P> RefUnwindSafe for Matrix<P>
where P: RefUnwindSafe,

§

impl<P> Send for Matrix<P>
where P: Send,

§

impl<P> Sync for Matrix<P>
where P: Sync,

§

impl<P> Unpin for Matrix<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for Matrix<P>

§

impl<P> UnwindSafe for Matrix<P>
where P: 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<P, L> PlaneOf<&L> for P
where P: PlaneOf<L>,

Source§

type Plane = <P as PlaneOf<L>>::Plane

Source§

fn get_plane(self, layout: &&L) -> Option<<P as PlaneOf<&L>>::Plane>

Get the layout describing the plane.
Source§

impl<P, L> PlaneOf<&mut L> for P
where P: PlaneOf<L>,

Source§

type Plane = <P as PlaneOf<L>>::Plane

Source§

fn get_plane(self, layout: &&mut L) -> Option<<P as PlaneOf<&mut L>>::Plane>

Get the layout describing the plane.
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 = 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.