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
impl Pivot
Sourcepub fn axis(&self) -> IVec2
pub fn axis(&self) -> IVec2
Coordinate axis for each pivot, used when transforming a point into the pivot’s coordinate space.
Sourcepub fn normalized(&self) -> Vec2
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.
Sourcepub fn transform_point(&self, grid_point: impl GridPoint) -> IVec2
pub fn transform_point(&self, grid_point: impl GridPoint) -> IVec2
Transform a point into the pivot’s coordinate space.
Sourcepub fn pivot_position(&self, grid_size: impl GridSize) -> IVec2
pub fn pivot_position(&self, grid_size: impl GridSize) -> IVec2
Calculate the position of a pivot on a sized grid.