Struct pixels_graphics_lib::prelude::Polygon
pub struct Polygon { /* private fields */ }
Implementations§
§impl Polygon
impl Polygon
pub fn fpoints(&self) -> &Vec<(f32, f32)>
pub fn is_regular(&self) -> bool
pub fn point_closest_to_center(&self) -> Coord
pub fn point_farthest_from_center(&self) -> Coord
pub fn is_convex(&self) -> bool
§impl Polygon
impl Polygon
pub fn as_inner_circle(&self) -> Circle
pub fn as_inner_circle(&self) -> Circle
Creates a circle using the point closest to the center
pub fn as_outer_circle(&self) -> Circle
pub fn as_outer_circle(&self) -> Circle
Creates a circle using the point farthest to the center
pub fn as_avg_circle(&self) -> Circle
pub fn as_avg_circle(&self) -> Circle
Creates a circle using the average point distance from the center
pub fn as_circle(&self) -> Option<Circle>
pub fn as_circle(&self) -> Option<Circle>
If the polygon is regular then it returns a circle from center to the first point
pub fn as_rect(&self) -> Rect
pub fn as_lines(&self) -> Vec<Line>
pub fn as_triangles(&self) -> Option<Vec<Triangle>>
pub fn as_triangles(&self) -> Option<Vec<Triangle>>
Cuts shape into triangles, triangles will be from the center to the edge This only works on convex polygons
Trait Implementations§
§impl ContainsShape for Polygon
impl ContainsShape for Polygon
§fn contains_rect(&self, rect: &Rect) -> bool
fn contains_rect(&self, rect: &Rect) -> bool
Returns true if
self
contains rect
§fn contains_circle(&self, circle: &Circle) -> bool
fn contains_circle(&self, circle: &Circle) -> bool
Returns true if
self
contains circle
§fn contains_line(&self, line: &Line) -> bool
fn contains_line(&self, line: &Line) -> bool
Returns true if
self
contains line
§fn contains_triangle(&self, triangle: &Triangle) -> bool
fn contains_triangle(&self, triangle: &Triangle) -> bool
Returns true if
self
contains triangle
§fn contains_polygon(&self, polygon: &Polygon) -> bool
fn contains_polygon(&self, polygon: &Polygon) -> bool
Returns true if
self
contains polygon
§impl<'de> Deserialize<'de> for Polygon
impl<'de> Deserialize<'de> for Polygon
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Polygon, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Polygon, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl IntersectsContains for Polygon
impl IntersectsContains for Polygon
§impl IntersectsShape for Polygon
impl IntersectsShape for Polygon
§fn intersects_rect(&self, rect: &Rect) -> bool
fn intersects_rect(&self, rect: &Rect) -> bool
Returns true if
rect
intersects self
§fn intersects_circle(&self, circle: &Circle) -> bool
fn intersects_circle(&self, circle: &Circle) -> bool
Returns true if
circle
intersects self
§fn intersects_line(&self, line: &Line) -> bool
fn intersects_line(&self, line: &Line) -> bool
Returns true if
line
intersects self
§fn intersects_triangle(&self, triangle: &Triangle) -> bool
fn intersects_triangle(&self, triangle: &Triangle) -> bool
Returns true if
triangle
intersects self
§fn intersects_ellipse(&self, ellipse: &Ellipse) -> bool
fn intersects_ellipse(&self, ellipse: &Ellipse) -> bool
Returns true if
ellipse
intersects self
§fn intersects_polygon(&self, polygon: &Polygon) -> bool
fn intersects_polygon(&self, polygon: &Polygon) -> bool
Returns true if
polygon
intersects self
§impl Serialize for Polygon
impl Serialize for Polygon
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
§impl Shape for Polygon
impl Shape for Polygon
§fn from_points(points: &[Coord]) -> Polygon
fn from_points(points: &[Coord]) -> Polygon
create this shape from a list of points (corners of a shape or tips of a line)
fn rebuild(&self, points: &[Coord]) -> Polygon
§fn 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
§fn 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
§fn translate_by(&self, delta: Coord) -> Selfwhere
Self: Sized,
fn translate_by(&self, delta: Coord) -> Selfwhere
Self: Sized,
change every point by +
delta
§fn 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) Read more§fn 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) Read more§fn 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
§fn 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)
§fn 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
impl StructuralPartialEq for Polygon
Auto Trait Implementations§
impl RefUnwindSafe for Polygon
impl Send for Polygon
impl Sync for Polygon
impl Unpin for Polygon
impl UnwindSafe for Polygon
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.