Pivot

Enum Pivot 

Source
pub enum Pivot {
    TopLeft,
    TopCenter,
    TopRight,
    LeftCenter,
    RightCenter,
    BottomLeft,
    BottomCenter,
    BottomRight,
    Center,
}
Expand description

A pivot on a 2d sized grid. Can be used to set positions relative to a given pivot. Each pivot has it’s own coordinate space it uses to calculate the final adjusted position.

Variants§

§

TopLeft

Coordinate space: X increases to the right, Y increases downwards.

§

TopCenter

Coordinate space: X increases to the right, Y increases downwards.

§

TopRight

Coordinate space: X increases to the left, Y increases downwards.

§

LeftCenter

Coordinate space: X increases to the right, Y increases upwards.

§

RightCenter

Coordinate space: X increases to the left, Y increases upwards.

§

BottomLeft

Coordinate space: X increases to the right, Y increases upwards.

§

BottomCenter

Coordinate space: X increases to the right, Y increases upwards.

§

BottomRight

Coordinate space: X increases to the left, Y increases upwards.

§

Center

Coordinate space: X increases to the right, Y increases upwards.

Implementations§

Source§

impl Pivot

Source

pub fn axis(&self) -> IVec2

Coordinate axis for each pivot, used when transforming a point into the pivot’s coordinate space.

Source

pub fn normalized(&self) -> Vec2

The normalized value of this pivot in default coordinate space where [0.0, 0.0] is the bottom left and [1.0, 1.0] is the top right.

Source

pub fn transform_point(&self, grid_point: impl GridPoint) -> IVec2

Transform a point into the pivot’s coordinate space.

Source

pub fn pivot_position(&self, grid_size: impl GridSize) -> IVec2

Calculate the position of a pivot on a sized grid.

Trait Implementations§

Source§

impl Clone for Pivot

Source§

fn clone(&self) -> Pivot

Returns a duplicate 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 Debug for Pivot

Source§

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

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

impl Ordinalize for Pivot

Source§

const VARIANT_COUNT: usize = 9usize

The count of variants.
Source§

const VARIANTS: &'static [Self]

List of this enum’s variants.
Source§

const VALUES: &'static [i8]

List of values for all variants of this enum.
Source§

type VariantType = i8

The type of the values of the variants.
Source§

fn ordinal(&self) -> i8

Retrieve the integer number of this variant.
Source§

unsafe fn from_ordinal_unsafe(number: i8) -> Self

Obtain a variant based on an integer number. Read more
Source§

fn from_ordinal(number: i8) -> Option<Self>

Obtain a variant based on an integer number.
Source§

impl PartialEq for Pivot

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Pivot

Source§

impl Eq for Pivot

Source§

impl StructuralPartialEq for Pivot

Auto Trait Implementations§

§

impl Freeze for Pivot

§

impl RefUnwindSafe for Pivot

§

impl Send for Pivot

§

impl Sync for Pivot

§

impl Unpin for Pivot

§

impl UnwindSafe for Pivot

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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

Source§

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

Source§

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.