Struct image_canvas::layout::CanvasLayout
source · [−]pub struct CanvasLayout { /* private fields */ }
Expand description
The layout of a full frame, with all planes and color.
Implementations
sourceimpl CanvasLayout
impl CanvasLayout
sourcepub fn with_plane(bytes: PlaneBytes) -> Self
pub fn with_plane(bytes: PlaneBytes) -> Self
Construct a full frame from a single plane.
sourcepub fn with_planes(
layers: &[PlaneBytes],
texel: Texel
) -> Result<Self, LayoutError>
pub fn with_planes(
layers: &[PlaneBytes],
texel: Texel
) -> Result<Self, LayoutError>
Create from a list of planes, and the texel they describe when merged.
sourcepub fn with_row_layout(rows: &RowLayoutDescription) -> Result<Self, LayoutError>
pub fn with_row_layout(rows: &RowLayoutDescription) -> Result<Self, LayoutError>
Create a buffer layout given the layout of a simple, strided matrix.
sourcepub fn with_texel(
texel: &Texel,
width: u32,
height: u32
) -> Result<Self, LayoutError>
pub fn with_texel(
texel: &Texel,
width: u32,
height: u32
) -> Result<Self, LayoutError>
Create a buffer layout from a texel and dimensions.
This is a simplification of with_row_layout
which itself is a simplified new
.
sourcepub fn texel(&self) -> &Texel
pub fn texel(&self) -> &Texel
Get the texel represented by the canvas as a whole.
For non-planar images this is exactly the same as the texel of the first place. Otherwise, it is a merged representation.
sourcepub fn texel_index(&self, x: u32, y: u32) -> u64
pub fn texel_index(&self, x: u32, y: u32) -> u64
Returns the index of a texel in a slice of planar image data.
sourcepub fn as_row_layout(&self) -> RowLayoutDescription
pub fn as_row_layout(&self) -> RowLayoutDescription
Returns a matrix descriptor that can store all bytes.
Note: for the moment, all layouts are row-wise matrices. This will be relaxed in the future to also permit the construction from planar image layouts. In this case, the method will return a descriptor that does not equal this layout. Instead, an image buffer shaped like the returned descriptor can be used to re-arrange all bytes into a simple matrix form.
sourcepub fn set_color(&mut self, color: Color) -> Result<(), LayoutError>
pub fn set_color(&mut self, color: Color) -> Result<(), LayoutError>
Set the color of the layout, if compatible with the texel.
pub fn as_plane(&self) -> Option<PlaneBytes>
Trait Implementations
sourceimpl Clone for CanvasLayout
impl Clone for CanvasLayout
sourcefn clone(&self) -> CanvasLayout
fn clone(&self) -> CanvasLayout
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for CanvasLayout
impl Debug for CanvasLayout
sourceimpl Decay<PlaneBytes> for CanvasLayout
impl Decay<PlaneBytes> for CanvasLayout
fn decay(from: PlaneBytes) -> Self
sourceimpl From<&PlaneBytes> for CanvasLayout
impl From<&PlaneBytes> for CanvasLayout
sourcefn from(plane: &PlaneBytes) -> Self
fn from(plane: &PlaneBytes) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<CanvasLayout> for CanvasLayout
impl PartialEq<CanvasLayout> for CanvasLayout
sourcefn eq(&self, other: &CanvasLayout) -> bool
fn eq(&self, other: &CanvasLayout) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &CanvasLayout) -> bool
fn ne(&self, other: &CanvasLayout) -> bool
This method tests for !=
.
impl StructuralPartialEq for CanvasLayout
Auto Trait Implementations
impl RefUnwindSafe for CanvasLayout
impl Send for CanvasLayout
impl Sync for CanvasLayout
impl Unpin for CanvasLayout
impl UnwindSafe for CanvasLayout
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more