pub struct Transform {
pub a: f32,
pub b: f32,
pub c: f32,
pub d: f32,
pub e: f32,
pub f: f32,
}Expand description
A 2D affine transform stored as a 2×3 matrix [a, b, c, d, e, f], mapping a
point (x, y) to (a*x + c*y + e, b*x + d*y + f). This is the same [f32; 6]
layout consumed by RenderNode::transform_with, so to_array() plugs in
directly. Compose with Transform::then instead of multiplying matrices by
hand.
Fields§
§a: f32§b: f32§c: f32§d: f32§e: f32§f: f32Implementations§
Source§impl Transform
impl Transform
pub const IDENTITY: Transform
Sourcepub fn scale_around(sx: f32, sy: f32, cx: f32, cy: f32) -> Self
pub fn scale_around(sx: f32, sy: f32, cx: f32, cy: f32) -> Self
Scale by (sx, sy) keeping the point (cx, cy) fixed.
Sourcepub fn rotate_around(angle_deg: f32, cx: f32, cy: f32) -> Self
pub fn rotate_around(angle_deg: f32, cx: f32, cy: f32) -> Self
Rotate by angle_deg degrees keeping the point (cx, cy) fixed.
Sourcepub fn then(self, next: Transform) -> Transform
pub fn then(self, next: Transform) -> Transform
Returns the transform that applies self first and then next
(next ∘ self), so a.then(b).apply(p) == b.apply(a.apply(p)).
pub fn apply(&self, p: Point) -> Point
pub fn to_array(&self) -> [f32; 6]
Sourcepub fn from_array(m: [f32; 6]) -> Transform
pub fn from_array(m: [f32; 6]) -> Transform
Rebuilds a Transform from the [a, b, c, d, e, f] layout produced by Transform::to_array.
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