Enum aglet::Direction4
source · [−]pub enum Direction4 {
North,
East,
South,
West,
}Expand description
Four-way directions.
These start at North and increment clockwise,
so you can convert them to integers with as and use them
in rotational calculations if you need.
Variants
North
East
South
West
Implementations
sourceimpl Direction4
impl Direction4
sourcepub const DIRECTIONS: [Direction4; 4] = _
pub const DIRECTIONS: [Direction4; 4] = _
All the directions in order. This is used internally for rotations and flips. I made it public just in case it’s helpful for you the programmer.
sourcepub fn rotate_by(self, steps_clockwise: i32) -> Self
pub fn rotate_by(self, steps_clockwise: i32) -> Self
Get this direction, rotated by this many steps clockwise. Negative numbers go counter-clockwise.
sourcepub fn radians(self) -> f32
pub fn radians(self) -> f32
Get this direction in radians.
This uses trigonometric + graphical standard, where:
- 0 radians is to the right
- Positive radians increment clockwise. NOTE: this is opposite from normal trig, but makes sense in computer graphics where +Y is downwards.
If you need it in degrees just call .to_degrees on the result.
sourcepub fn deltas(self) -> CoordVec
pub fn deltas(self) -> CoordVec
Get the deltas a step in this direction would result in, as a CoordVec.
sourcepub fn is_horizontal(self) -> bool
pub fn is_horizontal(self) -> bool
See if this direction points horizontally (ie, is East or West).
sourcepub fn is_vertical(self) -> bool
pub fn is_vertical(self) -> bool
See if this direction points vertically (ie, is North or South).
Trait Implementations
sourceimpl Add<Direction4> for CoordVec
impl Add<Direction4> for CoordVec
sourceimpl AddAssign<Direction4> for CoordVec
impl AddAssign<Direction4> for CoordVec
sourcefn add_assign(&mut self, rhs: Direction4)
fn add_assign(&mut self, rhs: Direction4)
Performs the += operation. Read more
sourceimpl Clone for Direction4
impl Clone for Direction4
sourcefn clone(&self) -> Direction4
fn clone(&self) -> Direction4
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Direction4
impl Debug for Direction4
sourceimpl From<Direction4> for Direction4Set
impl From<Direction4> for Direction4Set
sourcefn from(dir: Direction4) -> Self
fn from(dir: Direction4) -> Self
Converts to this type from the input type.
sourceimpl From<Direction4> for Direction8
impl From<Direction4> for Direction8
sourcefn from(d4: Direction4) -> Self
fn from(d4: Direction4) -> Self
Converts to this type from the input type.
sourceimpl Hash for Direction4
impl Hash for Direction4
sourceimpl Ord for Direction4
impl Ord for Direction4
sourceimpl PartialEq<Direction4> for Direction4
impl PartialEq<Direction4> for Direction4
sourceimpl PartialOrd<Direction4> for Direction4
impl PartialOrd<Direction4> for Direction4
sourcefn partial_cmp(&self, other: &Direction4) -> Option<Ordering>
fn partial_cmp(&self, other: &Direction4) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Copy for Direction4
impl Eq for Direction4
impl StructuralEq for Direction4
impl StructuralPartialEq for Direction4
Auto Trait Implementations
impl RefUnwindSafe for Direction4
impl Send for Direction4
impl Sync for Direction4
impl Unpin for Direction4
impl UnwindSafe for Direction4
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more