Trait pixel_engine::traits::ShapesTrait [−][src]
pub trait ShapesTrait: ScreenTrait {
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 ScreenTrait
to use it
Provided methods
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
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.
Draw a rectangle with the top left corner at (x, y)
and the bottom right corner at (x + w, y + h)
(both inclusive)
Fill a rectangle with the top left corner at (x, y)
and the bottom right corner at (x + w, y + h)
(both inclusive)
Draw a circle with center (x, y)
and raduis r
Fill a circle with center (x, y)
and raduis r
Draw the edges of a triangle between the three points