Struct pixels_graphics_lib::drawing::PixelWrapper
source · [−]pub struct PixelWrapper {
pub pixels: Pixels,
/* private fields */
}
Fields
pixels: Pixels
Implementations
sourceimpl PixelWrapper
impl PixelWrapper
sourceimpl PixelWrapper
impl PixelWrapper
sourcepub fn get_translate(&self) -> Point
pub fn get_translate(&self) -> Point
Get the canvas offset in pixels
sourcepub fn set_translate<P: Into<Point>>(&mut self, new_value: P)
pub fn set_translate<P: Into<Point>>(&mut self, new_value: P)
Set the canvas offset in pixels
All drawing commands will be offset by this value
sourcepub fn update_translate<P: Into<Point>>(&mut self, delta: P)
pub fn update_translate<P: Into<Point>>(&mut self, delta: P)
Adds delta
to the current canvas offset
sourceimpl PixelWrapper
impl PixelWrapper
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(&self, x: usize, y: usize, size: TextSize) -> (usize, usize)
pub fn get_px_for_char(&self, x: usize, y: usize, size: TextSize) -> (usize, usize)
Get top left pixel coord for letter px coord
sourceimpl PixelWrapper
impl PixelWrapper
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: TextPos, chr: char, size: TextSize, color: Color)
pub fn draw_letter(&mut self, pos: TextPos, chr: char, size: TextSize, color: Color)
Draw a letter at pos
sourcepub fn draw_text(
&mut self,
text: &str,
line_width: Option<usize>,
start_pos: TextPos,
size: TextSize,
color: Color
)
pub fn draw_text(
&mut self,
text: &str,
line_width: Option<usize>,
start_pos: TextPos,
size: TextSize,
color: Color
)
Draws text in lines at most width
chars long at pixel coord
Width should be max chars - x See TextSize::get_max_characters for maximum chars
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
Trait Implementations
sourceimpl DrawingMethods<f32> for PixelWrapper
impl DrawingMethods<f32> for PixelWrapper
sourcefn draw_image(&mut self, start_x: f32, start_y: f32, image: &Image)
fn draw_image(&mut self, start_x: f32, start_y: f32, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, color: Color)
fn draw_line(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, color: Color)
fn draw_rect(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, color: Color)
fn draw_frame(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: f32, y: f32, radius: f32, color: Color)
fn draw_circle(&mut self, x: f32, y: f32, radius: f32, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: f32, y: f32, radius: f32, color: Color)
fn draw_circle_filled(&mut self, x: f32, y: f32, radius: f32, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: f32, y: f32, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: f32, y: f32, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255
If use_translate
is true than the x,y will be updated with self.translate
Although the method takes &mut self
it doesn’t mutate anything
sourcefn update_pixel(&mut self, x: f32, y: f32, color: Color)
fn update_pixel(&mut self, x: f32, y: f32, color: Color)
Update a pixel color, using PixelWrapper::set_pixel or PixelWrapper::blend_pixel depending
on whether color
s alpha is 255 or not
sourceimpl DrawingMethods<f64> for PixelWrapper
impl DrawingMethods<f64> for PixelWrapper
sourcefn draw_image(&mut self, start_x: f64, start_y: f64, image: &Image)
fn draw_image(&mut self, start_x: f64, start_y: f64, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, color: Color)
fn draw_line(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, color: Color)
fn draw_rect(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, color: Color)
fn draw_frame(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: f64, y: f64, radius: f64, color: Color)
fn draw_circle(&mut self, x: f64, y: f64, radius: f64, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: f64, y: f64, radius: f64, color: Color)
fn draw_circle_filled(&mut self, x: f64, y: f64, radius: f64, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: f64, y: f64, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: f64, y: f64, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255
If use_translate
is true than the x,y will be updated with self.translate
Although the method takes &mut self
it doesn’t mutate anything
sourcefn update_pixel(&mut self, x: f64, y: f64, color: Color)
fn update_pixel(&mut self, x: f64, y: f64, color: Color)
Update a pixel color, using PixelWrapper::set_pixel or PixelWrapper::blend_pixel depending
on whether color
s alpha is 255 or not
sourceimpl DrawingMethods<i32> for PixelWrapper
impl DrawingMethods<i32> for PixelWrapper
sourcefn draw_image(&mut self, start_x: i32, start_y: i32, image: &Image)
fn draw_image(&mut self, start_x: i32, start_y: i32, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: Color)
fn draw_line(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: Color)
fn draw_rect(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: Color)
fn draw_frame(&mut self, x1: i32, y1: i32, x2: i32, y2: i32, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: i32, y: i32, radius: i32, color: Color)
fn draw_circle(&mut self, x: i32, y: i32, radius: i32, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: i32, y: i32, radius: i32, color: Color)
fn draw_circle_filled(&mut self, x: i32, y: i32, radius: i32, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: i32, y: i32, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: i32, y: i32, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255
If use_translate
is true than the x,y will be updated with self.translate
Although the method takes &mut self
it doesn’t mutate anything
sourcefn update_pixel(&mut self, x: i32, y: i32, color: Color)
fn update_pixel(&mut self, x: i32, y: i32, color: Color)
Update a pixel color, using PixelWrapper::set_pixel or PixelWrapper::blend_pixel depending
on whether color
s alpha is 255 or not
sourceimpl DrawingMethods<i64> for PixelWrapper
impl DrawingMethods<i64> for PixelWrapper
sourcefn draw_image(&mut self, start_x: i64, start_y: i64, image: &Image)
fn draw_image(&mut self, start_x: i64, start_y: i64, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: i64, y1: i64, x2: i64, y2: i64, color: Color)
fn draw_line(&mut self, x1: i64, y1: i64, x2: i64, y2: i64, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: i64, y1: i64, x2: i64, y2: i64, color: Color)
fn draw_rect(&mut self, x1: i64, y1: i64, x2: i64, y2: i64, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: i64, y1: i64, x2: i64, y2: i64, color: Color)
fn draw_frame(&mut self, x1: i64, y1: i64, x2: i64, y2: i64, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: i64, y: i64, radius: i64, color: Color)
fn draw_circle(&mut self, x: i64, y: i64, radius: i64, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: i64, y: i64, radius: i64, color: Color)
fn draw_circle_filled(&mut self, x: i64, y: i64, radius: i64, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: i64, y: i64, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: i64, y: i64, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255
If use_translate
is true than the x,y will be updated with self.translate
Although the method takes &mut self
it doesn’t mutate anything
sourcefn update_pixel(&mut self, x: i64, y: i64, color: Color)
fn update_pixel(&mut self, x: i64, y: i64, color: Color)
Update a pixel color, using PixelWrapper::set_pixel or PixelWrapper::blend_pixel depending
on whether color
s alpha is 255 or not
sourceimpl DrawingMethods<isize> for PixelWrapper
impl DrawingMethods<isize> for PixelWrapper
sourcefn draw_image(&mut self, start_x: isize, start_y: isize, image: &Image)
fn draw_image(&mut self, start_x: isize, start_y: isize, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: isize, y1: isize, x2: isize, y2: isize, color: Color)
fn draw_line(&mut self, x1: isize, y1: isize, x2: isize, y2: isize, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: isize, y1: isize, x2: isize, y2: isize, color: Color)
fn draw_rect(&mut self, x1: isize, y1: isize, x2: isize, y2: isize, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: isize, y1: isize, x2: isize, y2: isize, color: Color)
fn draw_frame(&mut self, x1: isize, y1: isize, x2: isize, y2: isize, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: isize, y: isize, radius: isize, color: Color)
fn draw_circle(&mut self, x: isize, y: isize, radius: isize, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: isize, y: isize, radius: isize, color: Color)
fn draw_circle_filled(&mut self, x: isize, y: isize, radius: isize, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: isize, y: isize, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: isize, y: isize, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255 Read more
sourcefn update_pixel(&mut self, x: isize, y: isize, color: Color)
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 Read more
sourceimpl DrawingMethods<u32> for PixelWrapper
impl DrawingMethods<u32> for PixelWrapper
sourcefn draw_image(&mut self, start_x: u32, start_y: u32, image: &Image)
fn draw_image(&mut self, start_x: u32, start_y: u32, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: u32, y1: u32, x2: u32, y2: u32, color: Color)
fn draw_line(&mut self, x1: u32, y1: u32, x2: u32, y2: u32, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: u32, y1: u32, x2: u32, y2: u32, color: Color)
fn draw_rect(&mut self, x1: u32, y1: u32, x2: u32, y2: u32, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: u32, y1: u32, x2: u32, y2: u32, color: Color)
fn draw_frame(&mut self, x1: u32, y1: u32, x2: u32, y2: u32, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: u32, y: u32, radius: u32, color: Color)
fn draw_circle(&mut self, x: u32, y: u32, radius: u32, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: u32, y: u32, radius: u32, color: Color)
fn draw_circle_filled(&mut self, x: u32, y: u32, radius: u32, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: u32, y: u32, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: u32, y: u32, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255
If use_translate
is true than the x,y will be updated with self.translate
Although the method takes &mut self
it doesn’t mutate anything
sourcefn update_pixel(&mut self, x: u32, y: u32, color: Color)
fn update_pixel(&mut self, x: u32, y: u32, color: Color)
Update a pixel color, using PixelWrapper::set_pixel or PixelWrapper::blend_pixel depending
on whether color
s alpha is 255 or not
sourceimpl DrawingMethods<u64> for PixelWrapper
impl DrawingMethods<u64> for PixelWrapper
sourcefn draw_image(&mut self, start_x: u64, start_y: u64, image: &Image)
fn draw_image(&mut self, start_x: u64, start_y: u64, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: u64, y1: u64, x2: u64, y2: u64, color: Color)
fn draw_line(&mut self, x1: u64, y1: u64, x2: u64, y2: u64, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: u64, y1: u64, x2: u64, y2: u64, color: Color)
fn draw_rect(&mut self, x1: u64, y1: u64, x2: u64, y2: u64, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: u64, y1: u64, x2: u64, y2: u64, color: Color)
fn draw_frame(&mut self, x1: u64, y1: u64, x2: u64, y2: u64, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: u64, y: u64, radius: u64, color: Color)
fn draw_circle(&mut self, x: u64, y: u64, radius: u64, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: u64, y: u64, radius: u64, color: Color)
fn draw_circle_filled(&mut self, x: u64, y: u64, radius: u64, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: u64, y: u64, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: u64, y: u64, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255
If use_translate
is true than the x,y will be updated with self.translate
Although the method takes &mut self
it doesn’t mutate anything
sourcefn update_pixel(&mut self, x: u64, y: u64, color: Color)
fn update_pixel(&mut self, x: u64, y: u64, color: Color)
Update a pixel color, using PixelWrapper::set_pixel or PixelWrapper::blend_pixel depending
on whether color
s alpha is 255 or not
sourceimpl DrawingMethods<usize> for PixelWrapper
impl DrawingMethods<usize> for PixelWrapper
sourcefn draw_image(&mut self, start_x: usize, start_y: usize, image: &Image)
fn draw_image(&mut self, start_x: usize, start_y: usize, image: &Image)
Draw an image at x
, y
sourcefn draw_line(&mut self, x1: usize, y1: usize, x2: usize, y2: usize, color: Color)
fn draw_line(&mut self, x1: usize, y1: usize, x2: usize, y2: usize, color: Color)
Draw line from x1,y1
to x2,y2
in color
sourcefn draw_rect(&mut self, x1: usize, y1: usize, x2: usize, y2: usize, color: Color)
fn draw_rect(&mut self, x1: usize, y1: usize, x2: usize, y2: usize, color: Color)
Draw a filled rectangle from x1,y1
to x2,y2
in color
sourcefn draw_frame(&mut self, x1: usize, y1: usize, x2: usize, y2: usize, color: Color)
fn draw_frame(&mut self, x1: usize, y1: usize, x2: usize, y2: usize, color: Color)
Draw a hollow rectangle from x1,y1
to x2,y2
in color
sourcefn draw_circle(&mut self, x: usize, y: usize, radius: usize, color: Color)
fn draw_circle(&mut self, x: usize, y: usize, radius: usize, color: Color)
Draw a hollow circle at x,y
with radius
in color
sourcefn draw_circle_filled(&mut self, x: usize, y: usize, radius: usize, color: Color)
fn draw_circle_filled(&mut self, x: usize, y: usize, radius: usize, color: Color)
Draw a filled circle at x,y
with radius
in color
sourcefn get_pixel(&mut self, x: usize, y: usize, use_translate: bool) -> Option<Color>
fn get_pixel(&mut self, x: usize, y: usize, use_translate: bool) -> Option<Color>
Get the RGB values for a pixel Alpha will always be 255
If use_translate
is true than the x,y will be updated with self.translate
Although the method takes &mut self
it doesn’t mutate anything
sourcefn update_pixel(&mut self, x: usize, y: usize, color: Color)
fn update_pixel(&mut self, x: usize, y: usize, color: Color)
Update a pixel color, using PixelWrapper::set_pixel or PixelWrapper::blend_pixel depending
on whether color
s alpha is 255 or not
Auto Trait Implementations
impl !RefUnwindSafe for PixelWrapper
impl Send for PixelWrapper
impl Sync for PixelWrapper
impl Unpin for PixelWrapper
impl !UnwindSafe for PixelWrapper
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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