Trait pixel_engine::traits::ShapesTrait
source · pub trait ShapesTrait: SmartDrawingTrait {
fn draw_text<P>(&mut self, pos: P, scale: u32, col: Color, text: &str)
where
P: Into<Vec2d<i32>>,
{ ... }
fn draw_line<P>(&mut self, p1: P, p2: P, col: Color)
where
P: Into<Vec2d<i32>>,
{ ... }
fn draw_rect<P>(&mut self, pos: P, size: P, col: Color)
where
P: Into<Vec2d<i32>>,
{ ... }
fn fill_rect<P>(&mut self, pos: P, size: P, col: Color)
where
P: Into<Vec2d<i32>>,
{ ... }
fn draw_circle<P>(&mut self, pos: P, r: u32, col: Color)
where
P: Into<Vec2d<i32>>,
{ ... }
fn fill_circle<P>(&mut self, pos: P, r: u32, col: Color)
where
P: Into<Vec2d<i32>>,
{ ... }
fn draw_triangle<P>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
where
P: Into<Vec2d<i32>>,
{ ... }
fn fill_triangle<P>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
where
P: Into<Vec2d<i32>>,
{ ... }
}
Expand description
A trait that regroups all the Shapes Drawing
You don’t need to implement anything other that DrawSpriteTrait
to use it
Provided Methods
sourcefn draw_text<P>(&mut self, pos: P, scale: u32, col: Color, text: &str)where
P: Into<Vec2d<i32>>,
fn draw_text<P>(&mut self, pos: P, scale: u32, col: Color, text: &str)where
P: Into<Vec2d<i32>>,
Draw text to the screen
scale
must be >= 1
The textsize will be equal to scale * 8
for the height and scale * 8 * text.len()
for
the width
This will handle \n
treating it as a new line, but wont do any newline stuff if it is
drawing out of the screen
sourcefn draw_line<P>(&mut self, p1: P, p2: P, col: Color)where
P: Into<Vec2d<i32>>,
fn draw_line<P>(&mut self, p1: P, p2: P, col: Color)where
P: Into<Vec2d<i32>>,
Draw a line between two points, You don’t need to do anything with the points for it to work, it will swap them it needed.
sourcefn draw_rect<P>(&mut self, pos: P, size: P, col: Color)where
P: Into<Vec2d<i32>>,
fn draw_rect<P>(&mut self, pos: P, size: P, col: Color)where
P: Into<Vec2d<i32>>,
Draw a rectangle with the top left corner at (x, y)
and the bottom right corner at (x + w, y + h)
(both inclusive)
sourcefn fill_rect<P>(&mut self, pos: P, size: P, col: Color)where
P: Into<Vec2d<i32>>,
fn fill_rect<P>(&mut self, pos: P, size: P, col: Color)where
P: Into<Vec2d<i32>>,
Fill a rectangle with the top left corner at (x, y)
and the bottom right corner at (x + w, y + h)
(both inclusive)
sourcefn draw_circle<P>(&mut self, pos: P, r: u32, col: Color)where
P: Into<Vec2d<i32>>,
fn draw_circle<P>(&mut self, pos: P, r: u32, col: Color)where
P: Into<Vec2d<i32>>,
Draw a circle with center (x, y)
and raduis r
sourcefn fill_circle<P>(&mut self, pos: P, r: u32, col: Color)where
P: Into<Vec2d<i32>>,
fn fill_circle<P>(&mut self, pos: P, r: u32, col: Color)where
P: Into<Vec2d<i32>>,
Fill a circle with center (x, y)
and raduis r