pub struct Transform {
pub translate_x: f32,
pub translate_y: f32,
pub scale_x: f32,
pub scale_y: f32,
pub rotate: f32,
pub shear_x: f32,
pub shear_y: f32,
pub origin_x: f32,
pub origin_y: f32,
}Fields§
§translate_x: f32§translate_y: f32§scale_x: f32§scale_y: f32§rotate: f32§shear_x: f32Horizontal shear factor (x += shear_x * y), e.g. ASS \fax.
shear_y: f32Vertical shear factor (y += shear_y * x), e.g. ASS \fay.
origin_x: f32§origin_y: f32Implementations§
Source§impl Transform
impl Transform
pub fn identity() -> Self
pub fn translate(x: f32, y: f32) -> Self
Sourcepub fn linear(&self) -> [f32; 4]
pub fn linear(&self) -> [f32; 4]
Forward 2x2 linear part (row-major [m00, m01, m10, m11]):
M = R(rotate) * H(shear) * S(scale) applied before translation.
Sourcepub fn linear_is_identity(&self) -> bool
pub fn linear_is_identity(&self) -> bool
Whether scale/rotation/shear are all identity (translation may apply).
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 outer, other inner) for a
transform stack: current.combine(pushed) where pushed is the
newly pushed (inner) node.
Returns a transform such that combined.apply_to_point(p) == self.apply_to_point(other.apply_to_point(p)).
The linear part is composed exactly (via polar decomposition of the
2x2 product); origins are inherited from self, matching the
previous behaviour for the shear-free cases.
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