pub struct Transform<F>where
F: Float,{ /* private fields */ }
Expand description
An affine transform for Pt values.
A series of translate, rotate, scale and skew transformations can be
combined into a single Transform
.
Example
use pointy::{Pt, Transform};
let t = Transform::with_translate(-50.0, -50.0)
.rotate(std::f32::consts::PI)
.translate(50.0, 50.0)
.scale(2.0, 2.0);
let pt = Pt::new(13.0, 5.5) * t;
let pt2 = (8.2, 4.7) * t;
let pt3 = t * (3.8, 9.6);
Implementations§
source§impl<F> Transform<F>where
F: Float,
impl<F> Transform<F>where
F: Float,
sourcepub fn with_translate(tx: F, ty: F) -> Self
pub fn with_translate(tx: F, ty: F) -> Self
Create a new translation transform.
tx
Amount to translate X.ty
Amount to translate Y.
sourcepub fn with_scale(sx: F, sy: F) -> Self
pub fn with_scale(sx: F, sy: F) -> Self
Create a new scale transform.
sx
Scale factor for X dimension.sy
Scale factor for Y dimension.
sourcepub fn with_rotate(th: F) -> Self
pub fn with_rotate(th: F) -> Self
Create a new rotation transform.
th
Angle to rotate coordinates (radians).
sourcepub fn with_skew(ax: F, ay: F) -> Self
pub fn with_skew(ax: F, ay: F) -> Self
Create a new skew transform.
ax
Angle to skew X-axis (radians).ay
Angle to skew Y-axis (radians).
sourcepub fn translate(self, tx: F, ty: F) -> Self
pub fn translate(self, tx: F, ty: F) -> Self
Apply translation to a transform.
tx
Amount to translate X.ty
Amount to translate Y.
sourcepub fn scale(self, sx: F, sy: F) -> Self
pub fn scale(self, sx: F, sy: F) -> Self
Apply scaling to a transform.
sx
Scale factor for X dimension.sy
Scale factor for Y dimension.
Trait Implementations§
source§impl<F> MulAssign for Transform<F>where
F: Float,
impl<F> MulAssign for Transform<F>where
F: Float,
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl<F> PartialEq for Transform<F>
impl<F> PartialEq for Transform<F>
impl<F> Copy for Transform<F>
impl<F> Eq for Transform<F>
impl<F> StructuralEq for Transform<F>where
F: Float,
impl<F> StructuralPartialEq for Transform<F>where
F: Float,
Auto Trait Implementations§
impl<F> RefUnwindSafe for Transform<F>where
F: RefUnwindSafe,
impl<F> Send for Transform<F>where
F: Send,
impl<F> Sync for Transform<F>where
F: Sync,
impl<F> Unpin for Transform<F>where
F: Unpin,
impl<F> UnwindSafe for Transform<F>where
F: UnwindSafe,
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