pub struct Transform { /* private fields */ }
Expand description
A transform builder type.
§Builder
The transform can be started by one of Transform::new_*
associated functions or Transform::identity
. More
transforms can be chained by calling the methods for each.
§Examples
Create a transform that
let rotate_then_move = Transform::new_rotate(10.deg()).translate(50, 30);
Implementations§
source§impl Transform
impl Transform
sourcepub fn new_rotate<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn new_rotate<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
Create a 2d rotation transform.
sourcepub fn new_rotate_x<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn new_rotate_x<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
Create a 3d rotation transform around the x axis.
sourcepub fn new_rotate_y<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn new_rotate_y<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
Create a 3d rotation transform around the y axis.
sourcepub fn new_rotate_z<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn new_rotate_z<A>(angle: A) -> Transformwhere
A: Into<AngleRadian>,
Same as new_rotate
.
sourcepub fn new_rotate_3d<A>(x: f32, y: f32, z: f32, angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn new_rotate_3d<A>(x: f32, y: f32, z: f32, angle: A) -> Transformwhere
A: Into<AngleRadian>,
Create a 3d rotation transform.
sourcepub fn new_translate<X, Y>(x: X, y: Y) -> Transform
pub fn new_translate<X, Y>(x: X, y: Y) -> Transform
Create a 2d translation transform.
sourcepub fn new_translate_3d<X, Y, Z>(x: X, y: Y, z: Z) -> Transform
pub fn new_translate_3d<X, Y, Z>(x: X, y: Y, z: Z) -> Transform
Create a 3d translation transform.
sourcepub fn new_translate_x<X>(x: X) -> Transform
pub fn new_translate_x<X>(x: X) -> Transform
Create a 2d translation transform in the X dimension.
sourcepub fn new_translate_y<Y>(y: Y) -> Transform
pub fn new_translate_y<Y>(y: Y) -> Transform
Create a 2d translation transform in the Y dimension.
sourcepub fn new_translate_z<Z>(z: Z) -> Transform
pub fn new_translate_z<Z>(z: Z) -> Transform
Create a 3d translation transform in the z dimension.
sourcepub fn new_perspective<D>(d: D) -> Transform
pub fn new_perspective<D>(d: D) -> Transform
Create a 3d perspective transform.
sourcepub fn new_skew_x<X>(x: X) -> Transformwhere
X: Into<AngleRadian>,
pub fn new_skew_x<X>(x: X) -> Transformwhere
X: Into<AngleRadian>,
Create a 2d skew transform in the X dimension.
sourcepub fn new_skew_y<Y>(y: Y) -> Transformwhere
Y: Into<AngleRadian>,
pub fn new_skew_y<Y>(y: Y) -> Transformwhere
Y: Into<AngleRadian>,
Create a 2d skew transform in the Y dimension.
sourcepub fn new_scale<S>(scale: S) -> Transform
pub fn new_scale<S>(scale: S) -> Transform
Create a 2d scale transform.
The same scale
is applied to both dimensions.
sourcepub fn new_scale_x<X>(x: X) -> Transform
pub fn new_scale_x<X>(x: X) -> Transform
Create a 2d scale transform on the X dimension.
sourcepub fn new_scale_y<Y>(y: Y) -> Transform
pub fn new_scale_y<Y>(y: Y) -> Transform
Create a 2d scale transform on the Y dimension.
source§impl Transform
impl Transform
sourcepub fn then(self, other: Transform) -> Transform
pub fn then(self, other: Transform) -> Transform
Change self
to apply other
after its transformation.
§Examples
Transform::new_rotate(10.deg()).then(Transform::new_translate(50, 30));
Is the equivalent of:
Transform::new_rotate(10.deg()).translate(50, 30);
sourcepub fn rotate<A>(self, angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn rotate<A>(self, angle: A) -> Transformwhere
A: Into<AngleRadian>,
Change self
to apply a 2d rotation after its transformation.
sourcepub fn rotate_x<A>(self, angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn rotate_x<A>(self, angle: A) -> Transformwhere
A: Into<AngleRadian>,
Change self
to apply a 3d rotation around the x axis.
Note that the composition of 3D rotations is usually not commutative, so the order this is applied will affect the result.
sourcepub fn rotate_y<A>(self, angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn rotate_y<A>(self, angle: A) -> Transformwhere
A: Into<AngleRadian>,
Change self
to apply a 3d rotation around the y axis.
Note that the composition of 3D rotations is usually not commutative, so the order this is applied will affect the result.
sourcepub fn rotate_3d<A>(self, x: f32, y: f32, z: f32, angle: A) -> Transformwhere
A: Into<AngleRadian>,
pub fn rotate_3d<A>(self, x: f32, y: f32, z: f32, angle: A) -> Transformwhere
A: Into<AngleRadian>,
Change self
to apply a 3d rotation.
Note that the composition of 3D rotations is usually not commutative, so the order this is applied will affect the result.
sourcepub fn translate<X, Y>(self, x: X, y: Y) -> Transform
pub fn translate<X, Y>(self, x: X, y: Y) -> Transform
Change self
to apply a 2d translation after its transformation.
sourcepub fn translate_x<X>(self, x: X) -> Transform
pub fn translate_x<X>(self, x: X) -> Transform
Change self
to apply a x translation after its transformation.
sourcepub fn translate_y<Y>(self, y: Y) -> Transform
pub fn translate_y<Y>(self, y: Y) -> Transform
Change self
to apply a y translation after its transformation.
sourcepub fn translate_z<Z>(self, z: Z) -> Transform
pub fn translate_z<Z>(self, z: Z) -> Transform
Change self
to apply a z translation after its transformation.
sourcepub fn translate_3d<X, Y, Z>(self, x: X, y: Y, z: Z) -> Transform
pub fn translate_3d<X, Y, Z>(self, x: X, y: Y, z: Z) -> Transform
Change self
to apply a 3d translation after its transformation.
Note that the composition of 3D rotations is usually not commutative, so the order this is applied will affect the result.
sourcepub fn skew<X, Y>(self, x: X, y: Y) -> Transform
pub fn skew<X, Y>(self, x: X, y: Y) -> Transform
Change self
to apply a 2d skew after its transformation.
sourcepub fn skew_x<X>(self, x: X) -> Transformwhere
X: Into<AngleRadian>,
pub fn skew_x<X>(self, x: X) -> Transformwhere
X: Into<AngleRadian>,
Change self
to apply a x skew after its transformation.
sourcepub fn skew_y<Y>(self, y: Y) -> Transformwhere
Y: Into<AngleRadian>,
pub fn skew_y<Y>(self, y: Y) -> Transformwhere
Y: Into<AngleRadian>,
Change self
to apply a y skew after its transformation.
sourcepub fn scale_xy<X, Y>(self, x: X, y: Y) -> Transform
pub fn scale_xy<X, Y>(self, x: X, y: Y) -> Transform
Change self
to apply a 2d scale after its transformation.
sourcepub fn scale_x<X>(self, x: X) -> Transform
pub fn scale_x<X>(self, x: X) -> Transform
Change self
to apply a x scale after its transformation.
sourcepub fn scale_y<Y>(self, y: Y) -> Transform
pub fn scale_y<Y>(self, y: Y) -> Transform
Change self
to apply a y scale after its transformation.
sourcepub fn scale<S>(self, scale: S) -> Transform
pub fn scale<S>(self, scale: S) -> Transform
Change self
to apply a uniform 2d scale after its transformation.
sourcepub fn perspective<D>(self, d: D) -> Transform
pub fn perspective<D>(self, d: D) -> Transform
Change self
3d perspective distance.
source§impl Transform
impl Transform
sourcepub fn layout(&self) -> PxTransform
pub fn layout(&self) -> PxTransform
Compute a PxTransform
in the current LAYOUT
context.
sourcepub fn try_layout(&self) -> Option<PxTransform>
pub fn try_layout(&self) -> Option<PxTransform>
Compute a PxTransform
if it is not affected by the layout context.
sourcepub fn needs_layout(&self) -> bool
pub fn needs_layout(&self) -> bool
Returns true
if this transform is affected by the layout context where it is evaluated.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Transform
impl<'de> Deserialize<'de> for Transform
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Transform, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Transform, <__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 Layout2d for Transform
impl Layout2d for Transform
source§type Px = PxTransform
type Px = PxTransform
source§fn layout_dft(
&self,
_: <Transform as Layout2d>::Px,
) -> <Transform as Layout2d>::Px
fn layout_dft( &self, _: <Transform as Layout2d>::Px, ) -> <Transform as Layout2d>::Px
LAYOUT
context with default
.source§fn affect_mask(&self) -> LayoutMask
fn affect_mask(&self) -> LayoutMask
LayoutMask
that flags all contextual values that affect the result of layout
.source§impl Serialize for Transform
impl Serialize for Transform
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,
source§impl Transitionable for Transform
impl Transitionable for Transform
impl IntoValue<Transform> for PxTransform
impl StructuralPartialEq for Transform
Auto Trait Implementations§
impl Freeze for Transform
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
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()
.