pub struct FrameBuffer { /* private fields */ }Expand description
A mutable RGBA pixel canvas.
Implementations§
Source§impl FrameBuffer
impl FrameBuffer
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
A width × height buffer, initially fully transparent.
Sourcepub fn pixel(&self, x: u32, y: u32) -> Rgba
pub fn pixel(&self, x: u32, y: u32) -> Rgba
The pixel at (x, y), or TRANSPARENT if out of bounds.
Sourcepub fn set(&mut self, x: u32, y: u32, color: Rgba)
pub fn set(&mut self, x: u32, y: u32, color: Rgba)
Overwrite the pixel at (x, y) (no blending); out-of-bounds is ignored.
Sourcepub fn blend(&mut self, x: u32, y: u32, color: Rgba)
pub fn blend(&mut self, x: u32, y: u32, color: Rgba)
Alpha-composite color over the pixel at (x, y).
Sourcepub fn fill_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Rgba)
pub fn fill_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Rgba)
Alpha-composite color over a rectangle (clipped to the buffer).
Sourcepub fn blit(&mut self, src: &FrameBuffer, dx: i32, dy: i32)
pub fn blit(&mut self, src: &FrameBuffer, dx: i32, dy: i32)
Alpha-composite the whole of src onto this buffer at (dx, dy).
Sourcepub fn blit_region(
&mut self,
src: &FrameBuffer,
sx: u32,
sy: u32,
sw: u32,
sh: u32,
dx: i32,
dy: i32,
)
pub fn blit_region( &mut self, src: &FrameBuffer, sx: u32, sy: u32, sw: u32, sh: u32, dx: i32, dy: i32, )
Alpha-composite a sw × sh region of src (from (sx, sy)) onto this
buffer at (dx, dy). Everything is clipped to both buffers.
Sourcepub fn shade(&mut self, f: impl Fn(u32, u32, Rgba) -> Rgba)
pub fn shade(&mut self, f: impl Fn(u32, u32, Rgba) -> Rgba)
Apply a per-pixel shader post-pass: f(x, y, current) returns the new
pixel. This is the terminal analog of a fragment shader — invert, tint,
fade, scanlines, etc.
Sourcepub fn to_image_data(&self) -> Option<ImageData>
pub fn to_image_data(&self) -> Option<ImageData>
Snapshot as ImageData for the Kitty/iTerm2/Sixel graphics path, or
None for a zero-sized buffer.
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