Trait graphics_shapes::Shape
source · pub trait Shape: AnyToAny {
Show 23 methods
// Required methods
fn from_points(points: &[Coord]) -> Self
where Self: Sized;
fn rebuild(&self, points: &[Coord]) -> Self
where Self: Sized;
fn contains(&self, point: Coord) -> bool;
fn points(&self) -> Vec<Coord>;
fn center(&self) -> Coord;
fn outline_pixels(&self) -> Vec<Coord>;
fn filled_pixels(&self) -> Vec<Coord>;
fn to_shape_box(&self) -> ShapeBox;
// Provided methods
fn translate_by(&self, delta: Coord) -> Self
where Self: Sized { ... }
fn move_to(&self, point: Coord) -> Self
where Self: Sized { ... }
fn move_center_to(&self, point: Coord) -> Self
where Self: Sized { ... }
fn rotate(&self, degrees: isize) -> Self
where Self: Sized { ... }
fn rotate_around(&self, degrees: isize, point: Coord) -> Self
where Self: Sized { ... }
fn left(&self) -> isize { ... }
fn right(&self) -> isize { ... }
fn top(&self) -> isize { ... }
fn bottom(&self) -> isize { ... }
fn top_left(&self) -> Coord { ... }
fn top_right(&self) -> Coord { ... }
fn bottom_left(&self) -> Coord { ... }
fn bottom_right(&self) -> Coord { ... }
fn scale(&self, factor: f32) -> Self
where Self: Sized { ... }
fn scale_around(&self, factor: f32, point: Coord) -> 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)
fn rebuild(&self, points: &[Coord]) -> Selfwhere
Self: Sized,
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
fn to_shape_box(&self) -> ShapeBox
Provided Methods§
sourcefn translate_by(&self, delta: Coord) -> Selfwhere
Self: Sized,
fn translate_by(&self, delta: Coord) -> Selfwhere
Self: Sized,
change every point by +delta
sourcefn move_to(&self, point: Coord) -> Selfwhere
Self: Sized,
fn move_to(&self, point: Coord) -> 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(&self, point: Coord) -> Selfwhere
Self: Sized,
fn move_center_to(&self, point: Coord) -> 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(&self, degrees: isize, point: Coord) -> Selfwhere
Self: Sized,
fn rotate_around(&self, degrees: isize, point: Coord) -> Selfwhere
Self: Sized,
Rotate shape around a point
fn top_left(&self) -> Coord
fn top_right(&self) -> Coord
fn bottom_left(&self) -> Coord
fn bottom_right(&self) -> Coord
sourcefn scale(&self, factor: f32) -> Selfwhere
Self: Sized,
fn scale(&self, factor: f32) -> Selfwhere
Self: Sized,
Scale the shape by factor (around the center, so the change will be uniform)
sourcefn scale_around(&self, factor: f32, point: Coord) -> Selfwhere
Self: Sized,
fn scale_around(&self, factor: f32, point: Coord) -> Selfwhere
Self: Sized,
Scale the shape by factor around point