pub struct Framebuffer { /* private fields */ }Expand description
A CPU-side pixel buffer storing 0xAARRGGBB values row-major.
Implementations§
Source§impl Framebuffer
impl Framebuffer
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
Allocate a transparent (all-zero) framebuffer of the given size.
Sourcepub fn with_fill(width: u32, height: u32, color: Color) -> Self
pub fn with_fill(width: u32, height: u32, color: Color) -> Self
Allocate a framebuffer pre-filled with color.
Sourcepub fn pixels_mut(&mut self) -> &mut [u32]
pub fn pixels_mut(&mut self) -> &mut [u32]
Mutably borrow the raw pixel slice.
Sourcepub fn clear(&mut self, color: Color)
pub fn clear(&mut self, color: Color)
Fill the entire buffer with color, discarding existing content.
Sourcepub fn get(&self, x: u32, y: u32) -> Option<u32>
pub fn get(&self, x: u32, y: u32) -> Option<u32>
Get the packed pixel at (x, y), or None if out of bounds.
Sourcepub fn get_rgba(&self, x: u32, y: u32) -> Option<(u8, u8, u8, u8)>
pub fn get_rgba(&self, x: u32, y: u32) -> Option<(u8, u8, u8, u8)>
Get the (r, g, b, a) components at (x, y), or None if out of bounds.
Sourcepub fn set(&mut self, x: u32, y: u32, px: u32)
pub fn set(&mut self, x: u32, y: u32, px: u32)
Set the packed pixel at (x, y) (overwrites; no blending). Out-of-bounds
writes are ignored.
Sourcepub fn blend(&mut self, x: u32, y: u32, src: u32)
pub fn blend(&mut self, x: u32, y: u32, src: u32)
Composite src over the existing pixel at (x, y) using straight-alpha
source-over blending. Out-of-bounds writes are ignored.
Sourcepub fn blend_coverage(&mut self, x: u32, y: u32, c: &Color, coverage: f32)
pub fn blend_coverage(&mut self, x: u32, y: u32, c: &Color, coverage: f32)
Blend a colour c with an extra coverage factor coverage in [0, 1]
(used for anti-aliased edges). The colour’s own alpha is multiplied by
coverage before compositing.
Sourcepub fn to_rgba_buffer(&self) -> RgbaBuffer
pub fn to_rgba_buffer(&self) -> RgbaBuffer
Convert to an RgbaBuffer (R, G, B, A bytes) suitable for PNG export.
Trait Implementations§
Source§impl Clone for Framebuffer
impl Clone for Framebuffer
Source§fn clone(&self) -> Framebuffer
fn clone(&self) -> Framebuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Framebuffer
impl RefUnwindSafe for Framebuffer
impl Send for Framebuffer
impl Sync for Framebuffer
impl Unpin for Framebuffer
impl UnsafeUnpin for Framebuffer
impl UnwindSafe for Framebuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more