Struct cursive::vec::Vec2 [] [src]

pub struct Vec2 {
    pub x: usize,
    pub y: usize,
}

Simple 2D size, in characters.

Fields

x: usize

X coordinate (column), from left to right.

y: usize

Y coordinate (row), from top to bottom.

Methods

impl Vec2
[src]

fn new(x: usize, y: usize) -> Self

Creates a new Vec2 from coordinates.

fn max(a: Self, b: Self) -> Self

Returns a new Vec2 that is a maximum per coordinate.

fn min(a: Self, b: Self) -> Self

Returns a new Vec2 that is no larger than any input in both dimensions.

fn keep_x(&self) -> Self

Returns a vector with the X component of self, and y=0.

fn keep_y(&self) -> Self

Returns a vector with the Y component of self, and x=0.

fn zero() -> Self

Alias for Vec::new(0,0).

fn stack_vertical(&self, other: &Vec2) -> Vec2

Returns (max(self.x,other.x), self.y+other.y)

fn stack_horizontal(&self, other: &Vec2) -> Vec2

Returns (self.x+other.x, max(self.y,other.y))

Trait Implementations

impl Debug for Vec2
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl PartialEq for Vec2
[src]

fn eq(&self, __arg_0: &Vec2) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Vec2) -> bool

This method tests for !=.

impl Copy for Vec2
[src]

impl Clone for Vec2
[src]

fn clone(&self) -> Vec2

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl PartialOrd for Vec2
[src]

fn partial_cmp(&self, other: &Vec2) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

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

This method tests less than (for self and other) and is used by the < operator. Read more

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

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

This method tests greater than (for self and other) and is used by the > operator. Read more

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl ToVec2 for Vec2
[src]

fn to_vec2(self) -> Vec2

Converts self into a Vec2.

impl<T: ToVec2> Add<T> for Vec2
[src]

type Output = Vec2

The resulting type after applying the + operator

fn add(self, other: T) -> Vec2

The method for the + operator

impl<T: ToVec2> Sub<T> for Vec2
[src]

type Output = Vec2

The resulting type after applying the - operator

fn sub(self, other: T) -> Vec2

The method for the - operator

impl Div<usize> for Vec2
[src]

type Output = Vec2

The resulting type after applying the / operator

fn div(self, other: usize) -> Vec2

The method for the / operator

impl Mul<usize> for Vec2
[src]

type Output = Vec2

The resulting type after applying the * operator

fn mul(self, other: usize) -> Vec2

The method for the * operator