Struct buffer_graphics_lib::Graphics
source · [−]pub struct Graphics<'buffer> { /* private fields */ }
Implementations
sourceimpl Graphics<'_>
impl Graphics<'_>
sourcepub fn get_translate(&self) -> Coord
pub fn get_translate(&self) -> Coord
Get the canvas offset in pixels
sourcepub fn set_translate(&mut self, new_value: Coord)
pub fn set_translate(&mut self, new_value: Coord)
Set the canvas offset in pixels
All drawing commands will be offset by this value
sourcepub fn update_translate(&mut self, delta: Coord)
pub fn update_translate(&mut self, delta: Coord)
Adds delta
to the current canvas offset
sourcepub fn copy_to_image(&mut self) -> Image
pub fn copy_to_image(&mut self) -> Image
Copy entire pixels array to an image
Although the method takes &mut self
it doesn’t mutate anything
sourcepub fn get_px_for_char(x: usize, y: usize, size: TextSize) -> (usize, usize)
pub fn get_px_for_char(x: usize, y: usize, size: TextSize) -> (usize, usize)
Get top left pixel coord for letter px coord
sourcepub fn draw_image<P: Into<Coord>>(&mut self, xy: P, image: &Image)
pub fn draw_image<P: Into<Coord>>(&mut self, xy: P, image: &Image)
Draw an image at x
, y
pub fn draw_line<P1: Into<Coord>, P2: Into<Coord>>(
&mut self,
start: P1,
end: P2,
color: Color
)
sourcepub fn draw_at<P: Into<Coord>>(&mut self, xy: P, shape: &dyn Renderable)
pub fn draw_at<P: Into<Coord>>(&mut self, xy: P, shape: &dyn Renderable)
Draw renderable
sourcepub fn draw(&mut self, shape: &dyn Renderable)
pub fn draw(&mut self, shape: &dyn Renderable)
Draw renderable
sourcepub fn update_pixel(&mut self, x: isize, y: isize, color: Color)
pub fn update_pixel(&mut self, x: isize, y: isize, color: Color)
Update a pixel color, using [PixelWrapper::set_pixel] or [PixelWrapper::blend_pixel] depending
on whether color
s alpha is 255 or not
sourcepub fn clear(&mut self, color: Color)
pub fn clear(&mut self, color: Color)
Sets every pixel to the same color, this ignores translate
sourcepub fn draw_letter(
&mut self,
pos: (isize, isize),
chr: char,
size: TextSize,
color: Color
)
pub fn draw_letter(
&mut self,
pos: (isize, isize),
chr: char,
size: TextSize,
color: Color
)
Draw a letter at pos
pub fn draw_ascii_letter(
&mut self,
pos: (isize, isize),
code: u8,
size: TextSize,
color: Color
)
sourcepub fn draw_ascii<P: Into<TextPos>, F: Into<TextFormat>>(
&mut self,
text: &[Vec<u8>],
pos: P,
format: F
)
pub fn draw_ascii<P: Into<TextPos>, F: Into<TextFormat>>(
&mut self,
text: &[Vec<u8>],
pos: P,
format: F
)
Should only be used by Text::render
text
param must already be corrected wrapped
pub fn draw_text<P: Into<TextPos>, F: Into<TextFormat>>(
&mut self,
text: &str,
pos: P,
format: F
)
sourcepub fn blend_pixel(&mut self, x: isize, y: isize, color: Color)
pub fn blend_pixel(&mut self, x: isize, y: isize, color: Color)
Set the RGB values for a pixel by blending it with the provided color This method uses alpha blending, note that the canvas pixels always have 255 alpha
Auto Trait Implementations
impl<'buffer> RefUnwindSafe for Graphics<'buffer>
impl<'buffer> Send for Graphics<'buffer>
impl<'buffer> Sync for Graphics<'buffer>
impl<'buffer> Unpin for Graphics<'buffer>
impl<'buffer> !UnwindSafe for Graphics<'buffer>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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