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 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 T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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,
§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> 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().