pub struct Transform {
pub translate_x: f32,
pub translate_y: f32,
pub scale_x: f32,
pub scale_y: f32,
pub rotate: f32,
}Fields§
§translate_x: f32§translate_y: f32§scale_x: f32§scale_y: f32§rotate: f32Implementations§
Source§impl Transform
impl Transform
pub fn identity() -> Self
pub fn translate(x: f32, y: f32) -> Self
pub fn apply_to_point(&self, p: Vec2) -> Vec2
pub fn apply_to_rect(&self, r: Rect) -> Rect
Sourcepub fn combine(&self, other: &Transform) -> Transform
pub fn combine(&self, other: &Transform) -> Transform
Compose two transforms: self then other (post-multiply).
Returns a transform such that combined.apply_to_point(p) == other.apply_to_point(self.apply_to_point(p)).
Limitation: the TRS representation is not closed under matrix multiplication when both transforms have rotation and non-uniform scale. In that case the result is an approximation (off-diagonal rotation/scale coupling is dropped). For UI use (uniform scale or no rotation) this is exact.
Trait Implementations§
impl Copy for Transform
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 UnsafeUnpin for Transform
impl UnwindSafe for Transform
Blanket Implementations§
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
Mutably borrows from an owned value. Read more