[][src]Struct semeion::space::Dimension

pub struct Dimension {
    pub x: i32,
    pub y: i32,
}

The dimension of a rectangular grid as the integer number of columns and rows.

Fields

x: i32y: i32

Implementations

impl Dimension[src]

pub fn with_eq_rectangles(count: usize) -> Self[src]

Constructs new dimension where the overall rectangle is composed by the lowest number of rectangles of equal size lower than the given count, so that they should be aligned in such a manner that the number of rows and number of columns are equal (with the last row possibly not being completely filled).

pub fn len(self) -> usize[src]

Gets the number of tiles in a grid of given Dimension, equal to the number of row by the number of columns.

pub fn is_empty(self) -> bool[src]

Returns true only if the number of tiles in the grid is 0.

pub fn is_square(self) -> bool[src]

Returns true only if the components of this Dimension are equal in magnitude, that is, self.x == self.y, and therefore this Dimension represents a square.

pub fn center(self) -> Location[src]

Gets the Location of the center of this Dimension.

pub fn contains(self, location: impl Into<Location>) -> bool[src]

Returns true only if the given Location is within this Dimension.

pub fn aspect_ratio(self) -> f32[src]

Gets the aspect ratio of this Dimension.

pub fn scale(self, other: impl Into<Self>) -> Self[src]

Maps self with the given Dimension, and returns the number of rows and columns (as new Dimension) that each tile of the given Dimension would have to occupy so that all its tiles would fill up self.

Trait Implementations

impl Clone for Dimension[src]

impl Copy for Dimension[src]

impl Debug for Dimension[src]

impl Default for Dimension[src]

impl Eq for Dimension[src]

impl From<(i32, i32)> for Dimension[src]

impl From<Dimension> for (i32, i32)[src]

impl Hash for Dimension[src]

impl Ord for Dimension[src]

impl PartialEq<Dimension> for Dimension[src]

impl PartialOrd<Dimension> for Dimension[src]

impl StructuralEq for Dimension[src]

impl StructuralPartialEq for Dimension[src]

Auto Trait Implementations

Blanket Implementations

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> 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.