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 more