Enum zng::layout::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 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 skew(alpha: Angle<f32>, beta: Angle<f32>) -> PxTransform
pub fn skew(alpha: Angle<f32>, beta: Angle<f32>) -> PxTransform
New 2D skew.
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) -> Transform
fn from(t: PxTransform) -> Transform
source§impl IntoVar<Transform> for PxTransform
impl IntoVar<Transform> for PxTransform
source§fn into_var(self) -> <PxTransform as IntoVar<Transform>>::Var
fn into_var(self) -> <PxTransform as IntoVar<Transform>>::Var
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl PartialEq for PxTransform
impl PartialEq for PxTransform
source§impl PxToWr for PxTransform
impl PxToWr for PxTransform
source§type AsDevice = Transform3D<f32, DevicePixel, DevicePixel>
type AsDevice = Transform3D<f32, DevicePixel, DevicePixel>
Self
equivalent in webrender::units::DevicePixel
units.source§type AsLayout = Transform3D<f32, LayoutPixel, LayoutPixel>
type AsLayout = Transform3D<f32, LayoutPixel, LayoutPixel>
Self
equivalent in webrender::units::LayoutPixel
units.source§type AsWorld = Transform3D<f32, WorldPixel, WorldPixel>
type AsWorld = Transform3D<f32, WorldPixel, WorldPixel>
Self
equivalent in `webrender::units::WorldPixel units.source§fn to_wr_device(self) -> <PxTransform as PxToWr>::AsDevice
fn to_wr_device(self) -> <PxTransform as PxToWr>::AsDevice
self
in webrender::units::DevicePixel
units.source§fn to_wr_world(self) -> <PxTransform as PxToWr>::AsWorld
fn to_wr_world(self) -> <PxTransform as PxToWr>::AsWorld
self
in webrender::units::WorldPixel
units.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§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.