pub struct FrameBuffer<M: PixelMap, const N: usize> { /* private fields */ }framebuffer only.Expand description
Frame buffer in the native GRAM layout M, drawn in the logical orientation
rotation.
Pixel coordinates and rows are logical, the bytes (Self::as_bytes) are
always native and are sent to the panel as they are. Changing the rotation
does not move the existing pixels: redraw the frame after
Self::set_rotation.
Implementations§
Source§impl<M: PixelMap, const N: usize> FrameBuffer<M, N>
impl<M: PixelMap, const N: usize> FrameBuffer<M, N>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Empty (all pixels off) buffer in Rotation::Deg0. N must equal
M::BUFFER_LEN (checked at compile time).
Sourcepub const fn with_rotation(self, rotation: Rotation) -> Self
pub const fn with_rotation(self, rotation: Rotation) -> Self
Same buffer with another orientation, see Self::set_rotation.
Sourcepub fn set_rotation(&mut self, rotation: Rotation)
pub fn set_rotation(&mut self, rotation: Rotation)
Changes the orientation of the coordinates. The buffer content is not touched, so the image turns into noise until it is redrawn.
Sourcepub const fn logical_size(&self) -> (u32, u32)
pub const fn logical_size(&self) -> (u32, u32)
Logical (width, height) for the current rotation.
Sourcepub fn set_pixel(&mut self, x: u32, y: u32, on: bool)
pub fn set_pixel(&mut self, x: u32, y: u32, on: bool)
Sets the logical pixel (x, y); coordinates outside the logical size
are ignored.
Sourcepub fn get_pixel(&self, x: u32, y: u32) -> Option<bool>
pub fn get_pixel(&self, x: u32, y: u32) -> Option<bool>
Reads the logical pixel (x, y), None outside the logical size.
Sourcepub fn fill(&mut self, on: bool)
pub fn fill(&mut self, on: bool)
Sets every pixel on or off. Same as DrawTarget::clear with
BinaryColor.
Sourcepub fn window(&self, area: Rectangle) -> Option<Window>
pub fn window(&self, area: Rectangle) -> Option<Window>
The GRAM window that covers the logical rectangle area (clipped to the logical size),
None if nothing of area is on the panel. Takes the rotation into account; see
Window::covering for the native version.
Sourcepub fn copy_window<'a>(&self, window: &Window, out: &'a mut [u8]) -> &'a [u8]
pub fn copy_window<'a>(&self, window: &Window, out: &'a mut [u8]) -> &'a [u8]
The bytes of window taken from the frame into out, ready for RAMWR after
set_address_window; returns &out[..window.byte_len()]. The window must come from
Self::window or Window::covering for the same M.
§Panics
If out is shorter than window.byte_len().
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Mutable native bytes. The layout is that of M, independent of the
rotation.
Sourcepub fn fill_with(&mut self, f: impl FnMut() -> u8)
pub fn fill_with(&mut self, f: impl FnMut() -> u8)
Fills the native bytes with values from f, in buffer order.
Sourcepub fn read_row(&self, y: u32, out: &mut [bool]) -> bool
pub fn read_row(&self, y: u32, out: &mut [bool]) -> bool
Reads a logical row y into out (out.len() == logical width).
Returns true if at least one pixel in the row is on.
A logical row is a native row (Deg0, Deg180) or a native column
(Deg90, Deg270), possibly in the reverse order, so every
orientation uses a whole-line path.
Sourcepub fn write_row(&mut self, y: u32, row: &[bool])
pub fn write_row(&mut self, y: u32, row: &[bool])
Writes a logical row y from row (row.len() == logical width). Only
sets pixels, never clears them: the row must be cleared beforehand
(see PixelMap::write_row).
Trait Implementations§
Source§impl<M: PixelMap, const N: usize> Debug for FrameBuffer<M, N>
Prints the geometry and the rotation, not the bytes.
impl<M: PixelMap, const N: usize> Debug for FrameBuffer<M, N>
Prints the geometry and the rotation, not the bytes.
Source§impl<M: PixelMap, const N: usize> DrawTarget for FrameBuffer<M, N>
impl<M: PixelMap, const N: usize> DrawTarget for FrameBuffer<M, N>
Source§fn clear(&mut self, color: Self::Color) -> Result<(), Self::Error>
fn clear(&mut self, color: Self::Color) -> Result<(), Self::Error>
Fills the whole buffer at once instead of pixel by pixel.