[][src]Struct paddle::Rectangle

pub struct Rectangle {
    pub pos: Vector,
    pub size: Vector,
}

A rectangle with a top-left position and a size

Fields

pos: Vector

The top-left coordinate of the rectangle

size: Vector

The width and height of the rectangle

Implementations

impl Rectangle[src]

pub fn new(pos: impl Into<Vector>, size: impl Into<Vector>) -> Rectangle[src]

Create a rectangle from a top-left vector and a size vector

pub fn new_sized(size: impl Into<Vector>) -> Rectangle[src]

Create a rectangle at the origin with the given size

pub fn top_left(&self) -> Vector[src]

Get the top left coordinate of the Rectangle

pub fn x(&self) -> f32[src]

Get the x-coordinate of the Rectangle (The origin of a Rectangle is at the top left)

pub fn y(&self) -> f32[src]

Get the y-coordinate of the Rectangle (The origin of a Rectangle is at the top left)

pub fn size(&self) -> Vector[src]

Get the size of the Rectangle

pub fn height(&self) -> f32[src]

Get the height of the Rectangle

pub fn width(&self) -> f32[src]

Get the width of the Rectangle

#[must_use]pub fn shrink_to_center(&self, shrink_to_center: f32) -> Rectangle[src]

#[must_use]pub fn padded(&self, padding: f32) -> Rectangle[src]

Padds constant pixels around the rectangle

#[must_use]pub fn shrink_and_fit_into(
    self,
    frame: &Rectangle,
    fit_strat: FitStrategy
) -> Rectangle
[src]

#[must_use]pub fn fit_into(&self, frame: &Rectangle, fit_strat: FitStrategy) -> Rectangle[src]

Shrinks (or grows) and moves the rectangle to fit within the given frame, without changing proportions

#[must_use]pub fn fit_into_ex(
    self,
    frame: &Rectangle,
    fit_strat: FitStrategy,
    allow_grow: bool
) -> Rectangle
[src]

Shrinks and moves the rectangle to fit within the given frame, without changing proportions

#[must_use]pub fn fit_square(&self, fit_strat: FitStrategy) -> Rectangle[src]

Finds the largest square that fits into the given rectangle

pub fn grid(&self, cols: usize, rows: usize) -> Grid

Notable traits for Grid

impl Iterator for Grid type Item = Rectangle;
[src]

#[must_use]pub fn cut_horizontal(&self, h: f32) -> (Rectangle, Rectangle)[src]

#[must_use]pub fn cut_vertical(&self, w: f32) -> (Rectangle, Rectangle)[src]

Trait Implementations

impl Clone for Rectangle[src]

impl Copy for Rectangle[src]

impl Debug for Rectangle[src]

impl Default for Rectangle[src]

impl<'de> Deserialize<'de> for Rectangle[src]

impl Eq for Rectangle[src]

impl Mul<Rectangle> for Transform[src]

type Output = Rectangle

The resulting type after applying the * operator.

impl Mul<Transform> for Rectangle[src]

Apply Transform to all points of a Rectangle

type Output = Rectangle

The resulting type after applying the * operator.

impl PartialEq<Rectangle> for Rectangle[src]

impl Serialize for Rectangle[src]

impl Shape for Rectangle[src]

impl Tessellate for Rectangle[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Activity for T where
    T: Any
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,