Trait graphics_shapes::Shape
source · pub trait Shape {
Show 17 methods
// Required methods
fn from_points(points: &[Coord]) -> Self
where Self: Sized;
fn contains<P: Into<Coord>>(&self, point: P) -> bool;
fn points(&self) -> Vec<Coord>;
fn center(&self) -> Coord;
fn outline_pixels(&self) -> Vec<Coord>;
fn filled_pixels(&self) -> Vec<Coord>;
// Provided methods
fn translate_by<P: Into<Coord>>(&self, delta: P) -> Self
where Self: Sized { ... }
fn move_to<P: Into<Coord>>(&self, point: P) -> Self
where Self: Sized { ... }
fn move_center_to<P: Into<Coord>>(&self, point: P) -> Self
where Self: Sized { ... }
fn rotate(&self, degrees: isize) -> Self
where Self: Sized { ... }
fn rotate_around<P: Into<Coord>>(&self, degrees: isize, point: P) -> Self
where Self: Sized { ... }
fn left(&self) -> isize { ... }
fn right(&self) -> isize { ... }
fn top(&self) -> isize { ... }
fn bottom(&self) -> isize { ... }
fn scale(&self, factor: f32) -> Self
where Self: Sized { ... }
fn scale_around<P: Into<Coord>>(&self, factor: f32, point: P) -> Self
where Self: Sized { ... }
}Required Methods§
sourcefn from_points(points: &[Coord]) -> Selfwhere
Self: Sized,
fn from_points(points: &[Coord]) -> Selfwhere Self: Sized,
create this shape from a list of points (corners of a shape or tips of a line)
sourcefn outline_pixels(&self) -> Vec<Coord>
fn outline_pixels(&self) -> Vec<Coord>
the coords for drawing the shape outline, the points may be in any order this should be cached rather than called per frame
sourcefn filled_pixels(&self) -> Vec<Coord>
fn filled_pixels(&self) -> Vec<Coord>
the coords for drawing the filled shape, the points may be in any order this should be cached rather than called per frame
Provided Methods§
sourcefn translate_by<P: Into<Coord>>(&self, delta: P) -> Selfwhere
Self: Sized,
fn translate_by<P: Into<Coord>>(&self, delta: P) -> Selfwhere Self: Sized,
change every point by +delta
sourcefn move_to<P: Into<Coord>>(&self, point: P) -> Selfwhere
Self: Sized,
fn move_to<P: Into<Coord>>(&self, point: P) -> Selfwhere Self: Sized,
moves the shapes first point to point
(and changes every other point to match their original distance and angle)
As this moves self.points()[0] the result might be unexpected if the shape was created right to left and/or bottom to top
sourcefn move_center_to<P: Into<Coord>>(&self, point: P) -> Selfwhere
Self: Sized,
fn move_center_to<P: Into<Coord>>(&self, point: P) -> Selfwhere Self: Sized,
moves the shapes center to point
(and changes every other point to match their original distance and angle)
As this moves relative to self.points()[0] the result might be unexpected if the shape was created right to left and/or bottom to top
sourcefn rotate_around<P: Into<Coord>>(&self, degrees: isize, point: P) -> Selfwhere
Self: Sized,
fn rotate_around<P: Into<Coord>>(&self, degrees: isize, point: P) -> Selfwhere Self: Sized,
rotate shape around a point