pub struct MutableSubgrid<'g, V = f32> { /* private fields */ }Expand description
A mutable subgrid of the underlying buffer.
Implementations§
Source§impl<'g, V> MutableSubgrid<'g, V>
impl<'g, V> MutableSubgrid<'g, V>
Sourcepub fn from_buf(
buf: &'g mut [V],
width: usize,
height: usize,
stride: usize,
) -> Self
pub fn from_buf( buf: &'g mut [V], width: usize, height: usize, stride: usize, ) -> Self
Create a MutableSubgrid from buffer slice, width, height and stride.
§Panic
Panics if:
widthis greater thanstride,- or the area specified by
width,heightandstrideis larger thanbuf.
Sourcepub fn get_ref(&self, x: usize, y: usize) -> &V
pub fn get_ref(&self, x: usize, y: usize) -> &V
Returns a reference to the sample at the given location.
§Panics
Panics if the coordinate is out of bounds.
Sourcepub fn try_get_ref(&self, x: usize, y: usize) -> Option<&V>
pub fn try_get_ref(&self, x: usize, y: usize) -> Option<&V>
Returns a reference to the sample at the given location, or None if it is out of bounds.
Sourcepub fn try_get_row(&self, row: usize) -> Option<&[V]>
pub fn try_get_row(&self, row: usize) -> Option<&[V]>
Returns a slice of a row of samples, or None if it is out of bounds.
Sourcepub fn get_mut(&mut self, x: usize, y: usize) -> &mut V
pub fn get_mut(&mut self, x: usize, y: usize) -> &mut V
Returns a mutable reference to the sample at the given location.
§Panics
Panics if the coordinate is out of bounds.
Sourcepub fn try_get_mut(&mut self, x: usize, y: usize) -> Option<&mut V>
pub fn try_get_mut(&mut self, x: usize, y: usize) -> Option<&mut V>
Returns a mutable reference to the sample at the given location, or None if it is out of
bounds.
Sourcepub fn get_row_mut(&mut self, row: usize) -> &mut [V]
pub fn get_row_mut(&mut self, row: usize) -> &mut [V]
Sourcepub fn try_get_row_mut(&mut self, row: usize) -> Option<&mut [V]>
pub fn try_get_row_mut(&mut self, row: usize) -> Option<&mut [V]>
Returns a mutable slice of a row of samples, or None if it is out of bounds.
Sourcepub fn swap(&mut self, (ax, ay): (usize, usize), (bx, by): (usize, usize))
pub fn swap(&mut self, (ax, ay): (usize, usize), (bx, by): (usize, usize))
Swaps two samples at the given locations.
§Panics
Panics if either one of the locations is out of bounds.
Sourcepub fn borrow_mut(&mut self) -> MutableSubgrid<'_, V>
pub fn borrow_mut(&mut self) -> MutableSubgrid<'_, V>
Reborrows the mutable subgrid, and returns a mutable subgrid with shorter lifetime.
Reborrows the mutable subgrid, and returns a shared subgrid.
Sourcepub fn subgrid(
self,
range_x: impl RangeBounds<usize>,
range_y: impl RangeBounds<usize>,
) -> MutableSubgrid<'g, V>
pub fn subgrid( self, range_x: impl RangeBounds<usize>, range_y: impl RangeBounds<usize>, ) -> MutableSubgrid<'g, V>
Sourcepub fn split_horizontal(
&mut self,
x: usize,
) -> (MutableSubgrid<'_, V>, MutableSubgrid<'_, V>)
pub fn split_horizontal( &mut self, x: usize, ) -> (MutableSubgrid<'_, V>, MutableSubgrid<'_, V>)
Sourcepub fn split_horizontal_in_place(&mut self, x: usize) -> MutableSubgrid<'g, V>
pub fn split_horizontal_in_place(&mut self, x: usize) -> MutableSubgrid<'g, V>
Sourcepub fn split_vertical(
&mut self,
y: usize,
) -> (MutableSubgrid<'_, V>, MutableSubgrid<'_, V>)
pub fn split_vertical( &mut self, y: usize, ) -> (MutableSubgrid<'_, V>, MutableSubgrid<'_, V>)
Sourcepub fn split_vertical_in_place(&mut self, y: usize) -> MutableSubgrid<'g, V>
pub fn split_vertical_in_place(&mut self, y: usize) -> MutableSubgrid<'g, V>
Sourcepub fn merge_horizontal_in_place(&mut self, right: Self)
pub fn merge_horizontal_in_place(&mut self, right: Self)
Merges the subgrid with another subgrid horizontally.
Two subgrids must be previously split from a subgrid using split_horizontal or
split_horizontal_in_place.
§Panics
Panics if two subgrids have not been split from the same subgrid.
Sourcepub fn merge_vertical_in_place(&mut self, bottom: Self)
pub fn merge_vertical_in_place(&mut self, bottom: Self)
Merges the subgrid with another subgrid vertically.
Two subgrids must be previously split from a subgrid using split_vertical or
split_vertical_in_place.
§Panics
Panics if two subgrids have not been split from the same subgrid.
Source§impl<V: Copy> MutableSubgrid<'_, V>
impl<V: Copy> MutableSubgrid<'_, V>
Source§impl<'g, V> MutableSubgrid<'g, V>
impl<'g, V> MutableSubgrid<'g, V>
Sourcepub fn into_groups(
self,
group_width: usize,
group_height: usize,
) -> Vec<MutableSubgrid<'g, V>>
pub fn into_groups( self, group_width: usize, group_height: usize, ) -> Vec<MutableSubgrid<'g, V>>
Returns a list of subgrids split into groups of given size, in row-first order.
Groups at the edge of the grid may have smaller sizes.
§Panics
Panics if either group_width or group_height is zero.
Sourcepub fn into_groups_with_fixed_count(
self,
group_width: usize,
group_height: usize,
num_cols: usize,
num_rows: usize,
) -> Vec<MutableSubgrid<'g, V>>
pub fn into_groups_with_fixed_count( self, group_width: usize, group_height: usize, num_cols: usize, num_rows: usize, ) -> Vec<MutableSubgrid<'g, V>>
Returns a list of subgrids split into groups of given size, with num_rows rows and
num_cols columns, in row-first order.
Unlike into_groups, this method will always return vector of length
num_cols * num_rows. Remaining rows or columns will be truncated, and groups out of
bounds will be zero-sized.
Source§impl MutableSubgrid<'_, f32>
impl MutableSubgrid<'_, f32>
Sourcepub fn as_vectored<V: SimdVector>(&mut self) -> Option<MutableSubgrid<'_, V>>
pub fn as_vectored<V: SimdVector>(&mut self) -> Option<MutableSubgrid<'_, V>>
Converts the grid to a grid of SIMD vectors, or None if the grid is not aligned to the
SIMD vector type.
§Panics
Panics if given SIMD vector type is not supported.
Source§impl<'g> MutableSubgrid<'g, f32>
impl<'g> MutableSubgrid<'g, f32>
Sourcepub fn into_i32(self) -> MutableSubgrid<'g, i32>
pub fn into_i32(self) -> MutableSubgrid<'g, i32>
Converts this subgrid into i32 subgrid.