Struct Affine
pub struct Affine {
pub a: f64,
pub b: f64,
pub c: f64,
pub d: f64,
pub tx: f64,
pub ty: f64,
}Expand description
A 2-D affine transform (CoreGraphics row-vector convention): a point p maps to
(a·p.x + c·p.y + tx, b·p.x + d·p.y + ty). Used by canvas transform ops for shape
rotate/scale/offset — every native 2-D context concatenates it onto its CTM identically.
Fields§
§a: f64§b: f64§c: f64§d: f64§tx: f64§ty: f64Implementations§
§impl Affine
impl Affine
pub const IDENTITY: Affine
pub const fn translate(x: f64, y: f64) -> Affine
pub const fn scale(sx: f64, sy: f64) -> Affine
pub fn rotate(radians: f64) -> Affine
pub fn rotate(radians: f64) -> Affine
Rotation by radians (counter-clockwise in a y-up space; clockwise on y-down screens).
pub fn then(self, o: Affine) -> Affine
pub fn then(self, o: Affine) -> Affine
self applied first, then other (row-vector product self · other).
pub fn apply(&self, p: Point) -> Point
pub fn invert_apply(&self, p: Point) -> Option<Point>
pub fn invert_apply(&self, p: Point) -> Option<Point>
Map a point back through the inverse (for hit-testing a transformed shape). None if singular.
pub fn is_identity(&self) -> bool
pub fn as_array(&self) -> [f64; 6]
pub fn from_array(m: [f64; 6]) -> Affine
Trait Implementations§
impl Copy for Affine
impl StructuralPartialEq for Affine
Auto Trait Implementations§
impl Freeze for Affine
impl RefUnwindSafe for Affine
impl Send for Affine
impl Sync for Affine
impl Unpin for Affine
impl UnsafeUnpin for Affine
impl UnwindSafe for Affine
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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