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 identity() -> PxTransform
pub fn identity() -> PxTransform
Identity transform.
sourcepub fn translation(x: f32, y: f32) -> PxTransform
pub fn translation(x: f32, y: f32) -> PxTransform
New simple 2D translation.
sourcepub fn translation_3d(x: f32, y: f32, z: f32) -> PxTransform
pub fn translation_3d(x: f32, y: f32, z: f32) -> PxTransform
New 3D translation.
sourcepub fn rotation_3d(x: f32, y: f32, z: f32, theta: Angle<f32>) -> PxTransform
pub fn rotation_3d(x: f32, y: f32, z: f32, theta: Angle<f32>) -> PxTransform
New 3D rotation.
sourcepub fn scale(x: f32, y: f32) -> PxTransform
pub fn scale(x: f32, y: f32) -> PxTransform
New 2D scale.
sourcepub fn perspective(d: f32) -> PxTransform
pub fn perspective(d: f32) -> PxTransform
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: Point2D<Px, Px>) -> Option<Point2D<Px, Px>>
pub fn transform_point(&self, point: Point2D<Px, Px>) -> Option<Point2D<Px, 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
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: Vector2D<Px, Px>) -> Vector2D<Px, Px>
pub fn transform_vector(&self, vector: Vector2D<Px, Px>) -> Vector2D<Px, Px>
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: Point2D<Px, Px>) -> Option<Point2D<Px, Px>>
pub fn project_point(&self, point: Point2D<Px, Px>) -> Option<Point2D<Px, Px>>
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.
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 Default for PxTransform
impl Default for PxTransform
source§fn default() -> PxTransform
fn default() -> PxTransform
Identity.
source§impl<'de> Deserialize<'de> for PxTransform
impl<'de> Deserialize<'de> for PxTransform
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PxTransform, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PxTransform, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<PxTransform> for Transform
impl From<PxTransform> for Transform
source§fn from(t: PxTransform) -> Self
fn from(t: PxTransform) -> Self
source§impl From<Transform3D<f32, Px, Px>> for PxTransform
impl From<Transform3D<f32, Px, Px>> for PxTransform
source§fn from(transform: Transform3D<f32, Px, Px>) -> PxTransform
fn from(transform: Transform3D<f32, Px, Px>) -> PxTransform
source§impl IntoVar<Transform> for PxTransform
impl IntoVar<Transform> for PxTransform
source§impl PartialEq for PxTransform
impl PartialEq for PxTransform
source§impl Serialize for PxTransform
impl Serialize for PxTransform
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for PxTransform
impl IntoValue<Transform> 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> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more