Struct graphics_shapes::triangle::Triangle

source ·
pub struct Triangle { /* private fields */ }

Implementations§

source§

impl Triangle

source

pub fn new<P1: Into<Coord>, P2: Into<Coord>, P3: Into<Coord>>( point1: P1, point2: P2, point3: P3, ) -> Self

source§

impl Triangle

source

pub fn angles(&self) -> [isize; 3]

source

pub fn angle_type(&self) -> &TriangleAngleType

source

pub fn side_type(&self) -> &TriangleSideType

source§

impl Triangle

source

pub fn as_rect(&self) -> Rect

source

pub fn as_lines(&self) -> [Line; 3]

source

pub fn right_angle<P: Into<Coord>>( angle_coord: P, size: usize, angle_position: AnglePosition, ) -> Triangle

Create an Isosceles Right Angle Triangle

source

pub fn equilateral<P: Into<Coord>>( center: P, size: usize, flat_side: FlatSide, ) -> Triangle

Create an equilateral triangle with width and height of [size] around [center] The top left would be (center.x - size / 2, center.y + size / 2) and bottom right (center.x + size / 2, center.y + size / 2)

Trait Implementations§

source§

impl Clone for Triangle

source§

fn clone(&self) -> Triangle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl ContainsShape for Triangle

source§

fn contains_circle(&self, circle: &Circle) -> bool

Returns true if self contains circle
source§

fn contains_rect(&self, rect: &Rect) -> bool
where Self: Shape + Sized,

Returns true if self contains rect
source§

fn contains_line(&self, line: &Line) -> bool
where Self: Shape + Sized,

Returns true if self contains line
source§

fn contains_triangle(&self, triangle: &Triangle) -> bool
where Self: Shape + Sized,

Returns true if self contains triangle
source§

fn contains_ellipse(&self, ellipse: &Ellipse) -> bool
where Self: Shape + Sized,

Returns true if self contains ellipse
source§

fn contains_polygon(&self, polygon: &Polygon) -> bool
where Self: Shape + Sized,

Returns true if self contains polygon
source§

impl Debug for Triangle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Triangle

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Triangle> for ShapeBox

source§

fn from(value: Triangle) -> Self

Converts to this type from the input type.
source§

impl Hash for Triangle

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl IntersectsContains for Triangle

source§

fn contains_shape(&self, other: &dyn Shape) -> Option<bool>

Returns Read more
source§

fn intersects_shape(&self, other: &dyn Shape) -> Option<bool>

Returns Read more
source§

impl IntersectsShape for Triangle

source§

fn intersects_rect(&self, rect: &Rect) -> bool

Returns true if rect intersects self
source§

fn intersects_circle(&self, circle: &Circle) -> bool

Returns true if circle intersects self
source§

fn intersects_line(&self, line: &Line) -> bool

Returns true if line intersects self
source§

fn intersects_triangle(&self, triangle: &Triangle) -> bool

Returns true if triangle intersects self
source§

fn intersects_ellipse(&self, ellipse: &Ellipse) -> bool

Returns true if ellipse intersects self
source§

fn intersects_polygon(&self, polygon: &Polygon) -> bool

Returns true if polygon intersects self
source§

impl PartialEq for Triangle

source§

fn eq(&self, other: &Triangle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Triangle

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Shape for Triangle

source§

fn from_points(points: &[Coord]) -> Self
where Self: Sized,

create this shape from a list of points (corners of a shape or tips of a line)
source§

fn rebuild(&self, points: &[Coord]) -> Self
where Self: Sized,

Used internally
source§

fn contains(&self, point: Coord) -> bool

Returns true if the shape contains point
source§

fn points(&self) -> Vec<Coord>

Points(corners/ends) the shape is made of
source§

fn center(&self) -> Coord

Center of shape
source§

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
source§

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
source§

fn to_shape_box(&self) -> ShapeBox

Convert to ShapeBox, used to store shapes with type (for bulk drawing, etc)
source§

fn translate_by(&self, delta: Coord) -> Self
where Self: Sized,

change every point by +delta
source§

fn move_to(&self, point: Coord) -> Self
where Self: Sized,

moves the shapes first point to point (and changes every other point to match their original distance and angle) Read more
source§

fn move_center_to(&self, point: Coord) -> Self
where Self: Sized,

Moves the shapes center to point (and changes every other point to match their original distance and angle) Read more
source§

fn rotate(&self, degrees: isize) -> Self
where Self: Sized,

Rotate shape around it’s center
source§

fn rotate_around(&self, degrees: isize, point: Coord) -> Self
where Self: Sized,

Rotate shape around a point
source§

fn left(&self) -> isize

x of the left most point
source§

fn right(&self) -> isize

x of the right most point
source§

fn top(&self) -> isize

y of the top most point
source§

fn bottom(&self) -> isize

y of the bottom most point
source§

fn top_left(&self) -> Coord

source§

fn top_right(&self) -> Coord

source§

fn bottom_left(&self) -> Coord

source§

fn bottom_right(&self) -> Coord

source§

fn scale(&self, factor: f32) -> Self
where Self: Sized,

Scale the shape by factor (around the center, so the change will be uniform)
source§

fn scale_around(&self, factor: f32, point: Coord) -> Self
where Self: Sized,

Scale the shape by factor around point
source§

impl Eq for Triangle

source§

impl StructuralPartialEq for Triangle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyToAny for T
where T: 'static,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,