Enum zng_unit::PxTransform
source · pub enum PxTransform {
Offset(Vector2D<f32, Px>),
Transform(Transform3D<f32, Px, Px>),
}
Expand description
A transform in device pixels.
Variants§
Implementations§
source§impl PxTransform
impl PxTransform
sourcepub fn translation(x: f32, y: f32) -> Self
pub fn translation(x: f32, y: f32) -> Self
New simple 2D translation.
sourcepub fn translation_3d(x: f32, y: f32, z: f32) -> Self
pub fn translation_3d(x: f32, y: f32, z: f32) -> Self
New 3D translation.
sourcepub fn perspective(d: f32) -> Self
pub fn perspective(d: f32) -> Self
New 3D perspective distance.
sourcepub fn to_transform(self) -> Transform3D<f32, Px, Px>
pub fn to_transform(self) -> Transform3D<f32, Px, Px>
To full transform.
sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns true
it is the identity transform.
sourcepub fn then(&self, other: &PxTransform) -> PxTransform
pub fn then(&self, other: &PxTransform) -> PxTransform
Returns the multiplication of the two matrices such that mat’s transformation applies after self’s transformation.
sourcepub fn then_translate(&self, offset: Vector2D<f32, Px>) -> PxTransform
pub fn then_translate(&self, offset: Vector2D<f32, Px>) -> PxTransform
Returns a transform with a translation applied after self’s transformation.
sourcepub fn pre_translate(&self, offset: Vector2D<f32, Px>) -> PxTransform
pub fn pre_translate(&self, offset: Vector2D<f32, Px>) -> PxTransform
Returns a transform with a translation applied before self’s transformation.
sourcepub fn is_invertible(&self) -> bool
pub fn is_invertible(&self) -> bool
Returns whether it is possible to compute the inverse transform.
sourcepub fn inverse(&self) -> Option<PxTransform>
pub fn inverse(&self) -> Option<PxTransform>
Returns the inverse transform if possible.
sourcepub fn is_2d(&self) -> bool
pub fn is_2d(&self) -> bool
Returns true
if this transform can be represented with a Transform2D
.
sourcepub fn transform_point(&self, point: PxPoint) -> Option<PxPoint>
pub fn transform_point(&self, point: PxPoint) -> Option<PxPoint>
Transform the pixel point.
Note that if the transform is 3D the point will be transformed with z=0, you can
use project_point
to find the 2D point in the 3D z-plane represented by the 3D
transform.
sourcepub fn transform_point_f32(
&self,
point: Point2D<f32, Px>,
) -> Option<Point2D<f32, Px>>
pub fn transform_point_f32( &self, point: Point2D<f32, Px>, ) -> Option<Point2D<f32, Px>>
Transform the pixel point.
Note that if the transform is 3D the point will be transformed with z=0, you can
use project_point_f32
to find the 2D point in the 3D z-plane represented by the 3D
transform.
sourcepub fn transform_vector(&self, vector: PxVector) -> PxVector
pub fn transform_vector(&self, vector: PxVector) -> PxVector
Transform the pixel vector.
sourcepub fn transform_vector_f32(
&self,
vector: Vector2D<f32, Px>,
) -> Vector2D<f32, Px>
pub fn transform_vector_f32( &self, vector: Vector2D<f32, Px>, ) -> Vector2D<f32, Px>
Transform the pixel vector.
sourcepub fn project_point(&self, point: PxPoint) -> Option<PxPoint>
pub fn project_point(&self, point: PxPoint) -> Option<PxPoint>
Project the 2D point onto the transform Z-plane.
sourcepub fn project_point_f32(
&self,
point: Point2D<f32, Px>,
) -> Option<Point2D<f32, Px>>
pub fn project_point_f32( &self, point: Point2D<f32, Px>, ) -> Option<Point2D<f32, Px>>
Project the 2D point onto the transform Z-plane.
sourcepub fn outer_transformed(&self, px_box: PxBox) -> Option<PxBox>
pub fn outer_transformed(&self, px_box: PxBox) -> Option<PxBox>
Returns a 2D box that encompasses the result of transforming the given box by this
transform, if the transform makes sense for it, or None
otherwise.
Trait Implementations§
source§impl Clone for PxTransform
impl Clone for PxTransform
source§fn clone(&self) -> PxTransform
fn clone(&self) -> PxTransform
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PxTransform
impl Debug for PxTransform
source§impl<'de> Deserialize<'de> for PxTransform
impl<'de> Deserialize<'de> for PxTransform
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for PxTransform
impl PartialEq for PxTransform
source§impl Serialize for PxTransform
impl Serialize for PxTransform
impl Copy for PxTransform
Auto Trait Implementations§
impl Freeze for PxTransform
impl RefUnwindSafe for PxTransform
impl Send for PxTransform
impl Sync for PxTransform
impl Unpin for PxTransform
impl UnwindSafe for PxTransform
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)