Trait pixel_engine_draw::traits::ShapesTrait
source · pub trait ShapesTrait: SmartDrawingTrait {
fn draw_text<P: Into<Vi2d>>(
&mut self,
pos: P,
scale: u32,
col: Color,
text: &str
) { ... }
fn draw_line<P: Into<Vi2d>>(&mut self, p1: P, p2: P, col: Color) { ... }
fn draw_rect<P: Into<Vi2d>>(&mut self, pos: P, size: P, col: Color) { ... }
fn fill_rect<P: Into<Vi2d>>(&mut self, pos: P, size: P, col: Color) { ... }
fn draw_circle<P: Into<Vi2d>>(&mut self, pos: P, r: u32, col: Color) { ... }
fn fill_circle<P: Into<Vi2d>>(&mut self, pos: P, r: u32, col: Color) { ... }
fn draw_triangle<P: Into<Vi2d>>(
&mut self,
pts1: P,
pts2: P,
pts3: P,
col: Color
) { ... }
fn fill_triangle<P: Into<Vi2d>>(
&mut self,
pts1: P,
pts2: P,
pts3: P,
col: Color
) { ... }
}
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: Into<Vi2d>>(&mut self, pos: P, scale: u32, col: Color, text: &str)
fn draw_text<P: Into<Vi2d>>(&mut self, pos: P, scale: u32, col: Color, text: &str)
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: Into<Vi2d>>(&mut self, p1: P, p2: P, col: Color)
fn draw_line<P: Into<Vi2d>>(&mut self, p1: P, p2: P, col: Color)
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: Into<Vi2d>>(&mut self, pos: P, size: P, col: Color)
fn draw_rect<P: Into<Vi2d>>(&mut self, pos: P, size: P, col: Color)
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: Into<Vi2d>>(&mut self, pos: P, size: P, col: Color)
fn fill_rect<P: Into<Vi2d>>(&mut self, pos: P, size: P, col: Color)
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: Into<Vi2d>>(&mut self, pos: P, r: u32, col: Color)
fn draw_circle<P: Into<Vi2d>>(&mut self, pos: P, r: u32, col: Color)
Draw a circle with center (x, y)
and raduis r
sourcefn fill_circle<P: Into<Vi2d>>(&mut self, pos: P, r: u32, col: Color)
fn fill_circle<P: Into<Vi2d>>(&mut self, pos: P, r: u32, col: Color)
Fill a circle with center (x, y)
and raduis r
sourcefn draw_triangle<P: Into<Vi2d>>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
fn draw_triangle<P: Into<Vi2d>>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
Draw the edges of a triangle between the three points
sourcefn fill_triangle<P: Into<Vi2d>>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
fn fill_triangle<P: Into<Vi2d>>(&mut self, pts1: P, pts2: P, pts3: P, col: Color)
Fill the given triangle