pub struct Rect { /* private fields */ }
Expand description

Rectangle

Must have flat edges, to rotate first convert to Polygon using Rect::as_polygon()

Implementations§

source§

impl Rect

source

pub fn new<P1, P2>(top_left: P1, bottom_right: P2) -> Rectwhere P1: Into<Coord>, P2: Into<Coord>,

source

pub fn new_with_size<P>(start: P, width: usize, height: usize) -> Rectwhere P: Into<Coord>,

source§

impl Rect

source

pub fn width(&self) -> usize

source

pub fn height(&self) -> usize

source

pub fn top_left(&self) -> Coord

source

pub fn bottom_right(&self) -> Coord

source

pub fn is_square(&self) -> bool

source§

impl Rect

source

pub fn as_smallest_circle(&self) -> Circle

Create a circle around the center to the closest edge

source

pub fn as_biggest_circle(&self) -> Circle

Create a circle around the center to the farthest edge

source

pub fn as_triangles(&self) -> (Triangle, Triangle)

Create two triangles

source

pub fn as_polygon(&self) -> Polygon

Same shape but represented as four points/lines instead of two points

source

pub fn as_ellipse(&self) -> Ellipse

Trait Implementations§

source§

impl Clone for Rect

source§

fn clone(&self) -> Rect

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 CreateDrawable<Rect> for Drawable<Rect>

source§

fn from_obj(rect: Rect, draw_type: DrawType) -> Drawable<Rect>

source§

impl Debug for Rect

source§

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

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

impl FromDrawable<Rect> for ShapeBox

source§

impl FromShape<Rect> for ShapeBox

source§

fn from_shape(shape: Rect, draw_type: DrawType) -> ShapeBox

source§

impl PartialEq<Rect> for Rect

source§

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

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

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

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

impl Renderable<Rect> for Drawable<Rect>

source§

fn render(&self, graphics: &mut Graphics<'_>)

source§

impl Shape for Rect

source§

fn from_points(points: &[Coord]) -> Rectwhere Rect: Sized,

create this shape from a list of points
source§

fn contains<P>(&self, point: P) -> boolwhere P: Into<Coord>,

returns true if the shape contains point
source§

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

points(corners) the shape is made of
source§

fn rotate_around<P>(&self, degrees: isize, point: P) -> Rectwhere P: Into<Coord>, Rect: Sized,

rotate shape around a point
source§

fn center(&self) -> Coord

center of shape
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 translate_by<P>(&self, delta: P) -> Selfwhere P: Into<Coord>, Self: Sized,

change every point by +delta
source§

fn move_to<P>(&self, point: P) -> Selfwhere P: Into<Coord>, 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<P>(&self, point: P) -> Selfwhere P: Into<Coord>, Self: Sized,

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

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

rotate shape around it’s center
source§

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

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

fn scale_around<P>(&self, factor: f32, point: P) -> Selfwhere P: Into<Coord>, Self: Sized,

scale the shape by factor around point
source§

impl Eq for Rect

source§

impl StructuralEq for Rect

source§

impl StructuralPartialEq for Rect

Auto Trait Implementations§

§

impl RefUnwindSafe for Rect

§

impl Send for Rect

§

impl Sync for Rect

§

impl Unpin for Rect

§

impl UnwindSafe for Rect

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.