Struct zng_layout::unit::Transform
source · 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: Into<AngleRadian>>(angle: A) -> Transform
pub fn new_rotate<A: Into<AngleRadian>>(angle: A) -> Transform
Create a 2d rotation transform.
sourcepub fn new_rotate_x<A: Into<AngleRadian>>(angle: A) -> Transform
pub fn new_rotate_x<A: Into<AngleRadian>>(angle: A) -> Transform
Create a 3d rotation transform around the x axis.
sourcepub fn new_rotate_y<A: Into<AngleRadian>>(angle: A) -> Transform
pub fn new_rotate_y<A: Into<AngleRadian>>(angle: A) -> Transform
Create a 3d rotation transform around the y axis.
sourcepub fn new_rotate_z<A: Into<AngleRadian>>(angle: A) -> Transform
pub fn new_rotate_z<A: Into<AngleRadian>>(angle: A) -> Transform
Same as new_rotate
.
sourcepub fn new_rotate_3d<A: Into<AngleRadian>>(
x: f32,
y: f32,
z: f32,
angle: A,
) -> Transform
pub fn new_rotate_3d<A: Into<AngleRadian>>( x: f32, y: f32, z: f32, angle: A, ) -> Transform
Create a 3d rotation transform.
sourcepub fn new_translate<X: Into<Length>, Y: Into<Length>>(x: X, y: Y) -> Transform
pub fn new_translate<X: Into<Length>, Y: Into<Length>>(x: X, y: Y) -> Transform
Create a 2d translation transform.
sourcepub fn new_translate_3d<X: Into<Length>, Y: Into<Length>, Z: Into<Length>>(
x: X,
y: Y,
z: Z,
) -> Transform
pub fn new_translate_3d<X: Into<Length>, Y: Into<Length>, Z: Into<Length>>( x: X, y: Y, z: Z, ) -> Transform
Create a 3d translation transform.
sourcepub fn new_translate_x<X: Into<Length>>(x: X) -> Transform
pub fn new_translate_x<X: Into<Length>>(x: X) -> Transform
Create a 2d translation transform in the X dimension.
sourcepub fn new_translate_y<Y: Into<Length>>(y: Y) -> Transform
pub fn new_translate_y<Y: Into<Length>>(y: Y) -> Transform
Create a 2d translation transform in the Y dimension.
sourcepub fn new_translate_z<Z: Into<Length>>(z: Z) -> Transform
pub fn new_translate_z<Z: Into<Length>>(z: Z) -> Transform
Create a 3d translation transform in the z dimension.
sourcepub fn new_perspective<D: Into<Length>>(d: D) -> Transform
pub fn new_perspective<D: Into<Length>>(d: D) -> Transform
Create a 3d perspective transform.
sourcepub fn new_skew<X: Into<AngleRadian>, Y: Into<AngleRadian>>(
x: X,
y: Y,
) -> Transform
pub fn new_skew<X: Into<AngleRadian>, Y: Into<AngleRadian>>( x: X, y: Y, ) -> Transform
Create a 2d skew transform.
sourcepub fn new_skew_x<X: Into<AngleRadian>>(x: X) -> Transform
pub fn new_skew_x<X: Into<AngleRadian>>(x: X) -> Transform
Create a 2d skew transform in the X dimension.
sourcepub fn new_skew_y<Y: Into<AngleRadian>>(y: Y) -> Transform
pub fn new_skew_y<Y: Into<AngleRadian>>(y: Y) -> Transform
Create a 2d skew transform in the Y dimension.
sourcepub fn new_scale<S: Into<Factor>>(scale: S) -> Transform
pub fn new_scale<S: Into<Factor>>(scale: S) -> Transform
Create a 2d scale transform.
The same scale
is applied to both dimensions.
sourcepub fn new_scale_x<X: Into<Factor>>(x: X) -> Transform
pub fn new_scale_x<X: Into<Factor>>(x: X) -> Transform
Create a 2d scale transform on the X dimension.
sourcepub fn new_scale_y<Y: Into<Factor>>(y: Y) -> Transform
pub fn new_scale_y<Y: Into<Factor>>(y: Y) -> Transform
Create a 2d scale transform on the Y dimension.
source§impl Transform
impl Transform
sourcepub fn then(self, other: Transform) -> Self
pub fn then(self, other: Transform) -> Self
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: Into<AngleRadian>>(self, angle: A) -> Self
pub fn rotate<A: Into<AngleRadian>>(self, angle: A) -> Self
Change self
to apply a 2d rotation after its transformation.
sourcepub fn rotate_x<A: Into<AngleRadian>>(self, angle: A) -> Self
pub fn rotate_x<A: Into<AngleRadian>>(self, angle: A) -> Self
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: Into<AngleRadian>>(self, angle: A) -> Self
pub fn rotate_y<A: Into<AngleRadian>>(self, angle: A) -> Self
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_z<A: Into<AngleRadian>>(self, angle: A) -> Self
pub fn rotate_z<A: Into<AngleRadian>>(self, angle: A) -> Self
Same as rotate
.
sourcepub fn rotate_3d<A: Into<AngleRadian>>(
self,
x: f32,
y: f32,
z: f32,
angle: A,
) -> Self
pub fn rotate_3d<A: Into<AngleRadian>>( self, x: f32, y: f32, z: f32, angle: A, ) -> Self
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: Into<Length>, Y: Into<Length>>(self, x: X, y: Y) -> Self
pub fn translate<X: Into<Length>, Y: Into<Length>>(self, x: X, y: Y) -> Self
Change self
to apply a 2d translation after its transformation.
sourcepub fn translate_x<X: Into<Length>>(self, x: X) -> Self
pub fn translate_x<X: Into<Length>>(self, x: X) -> Self
Change self
to apply a x translation after its transformation.
sourcepub fn translate_y<Y: Into<Length>>(self, y: Y) -> Self
pub fn translate_y<Y: Into<Length>>(self, y: Y) -> Self
Change self
to apply a y translation after its transformation.
sourcepub fn translate_z<Z: Into<Length>>(self, z: Z) -> Self
pub fn translate_z<Z: Into<Length>>(self, z: Z) -> Self
Change self
to apply a z translation after its transformation.
sourcepub fn translate_3d<X: Into<Length>, Y: Into<Length>, Z: Into<Length>>(
self,
x: X,
y: Y,
z: Z,
) -> Self
pub fn translate_3d<X: Into<Length>, Y: Into<Length>, Z: Into<Length>>( self, x: X, y: Y, z: Z, ) -> Self
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: Into<AngleRadian>, Y: Into<AngleRadian>>(
self,
x: X,
y: Y,
) -> Self
pub fn skew<X: Into<AngleRadian>, Y: Into<AngleRadian>>( self, x: X, y: Y, ) -> Self
Change self
to apply a 2d skew after its transformation.
sourcepub fn skew_x<X: Into<AngleRadian>>(self, x: X) -> Self
pub fn skew_x<X: Into<AngleRadian>>(self, x: X) -> Self
Change self
to apply a x skew after its transformation.
sourcepub fn skew_y<Y: Into<AngleRadian>>(self, y: Y) -> Self
pub fn skew_y<Y: Into<AngleRadian>>(self, y: Y) -> Self
Change self
to apply a y skew after its transformation.
sourcepub fn scale_xy<X: Into<Factor>, Y: Into<Factor>>(self, x: X, y: Y) -> Self
pub fn scale_xy<X: Into<Factor>, Y: Into<Factor>>(self, x: X, y: Y) -> Self
Change self
to apply a 2d scale after its transformation.
sourcepub fn scale_x<X: Into<Factor>>(self, x: X) -> Self
pub fn scale_x<X: Into<Factor>>(self, x: X) -> Self
Change self
to apply a x scale after its transformation.
sourcepub fn scale_y<Y: Into<Factor>>(self, y: Y) -> Self
pub fn scale_y<Y: Into<Factor>>(self, y: Y) -> Self
Change self
to apply a y scale after its transformation.
sourcepub fn scale<S: Into<Factor>>(self, scale: S) -> Self
pub fn scale<S: Into<Factor>>(self, scale: S) -> Self
Change self
to apply a uniform 2d scale after its transformation.
sourcepub fn perspective<D: Into<Length>>(self, d: D) -> Self
pub fn perspective<D: Into<Length>>(self, d: D) -> Self
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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 IntoVar<Transform> for PxTransform
impl IntoVar<Transform> for PxTransform
source§impl Layout2d for Transform
impl Layout2d for Transform
source§type Px = PxTransform
type Px = PxTransform
source§fn layout_dft(&self, _: Self::Px) -> Self::Px
fn layout_dft(&self, _: Self::Px) -> Self::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 Transitionable for Transform
impl Transitionable for Transform
source§fn lerp(self, to: &Self, step: EasingStep) -> Self
fn lerp(self, to: &Self, step: EasingStep) -> Self
self
-> to
by step
.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§
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