pub struct Transform { /* private fields */ }
Expand description
An affine transform can translate, scale, rotate and skew 2D points.
A series of transforms can be combined into a single Transform struct. This can be used by a Plotter to alter subsequent points.
Example
use footile::Transform;
const PI: f32 = std::f32::consts::PI;
let t = Transform::new_translate(-50.0, -50.0)
.rotate(PI)
.translate(50.0, 50.0)
.scale(2.0, 2.0);
Implementations
sourceimpl Transform
impl Transform
sourcepub fn new_translate(tx: f32, ty: f32) -> Self
pub fn new_translate(tx: f32, ty: f32) -> Self
Create a new translation transform.
tx
Amount to translate X.ty
Amount to translate Y.
sourcepub fn new_scale(sx: f32, sy: f32) -> Self
pub fn new_scale(sx: f32, sy: f32) -> Self
Create a new scale transform.
sx
Scale factor for X dimension.sy
Scale factor for Y dimension.
sourcepub fn new_rotate(th: f32) -> Self
pub fn new_rotate(th: f32) -> Self
Create a new rotation transform.
th
Angle to rotate coordinates (radians).
sourcepub fn new_skew(ax: f32, ay: f32) -> Self
pub fn new_skew(ax: f32, ay: f32) -> 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: f32, ty: f32) -> Self
pub fn translate(self, tx: f32, ty: f32) -> Self
Apply translation to a transform.
tx
Amount to translate X.ty
Amount to translate Y.
sourcepub fn scale(self, sx: f32, sy: f32) -> Self
pub fn scale(self, sx: f32, sy: f32) -> Self
Apply scaling to a transform.
sx
Scale factor for X dimension.sy
Scale factor for Y dimension.
Trait Implementations
sourceimpl MulAssign<Transform> for Transform
impl MulAssign<Transform> for Transform
sourcefn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
Performs the
*=
operation. Read moreimpl Copy for Transform
impl StructuralPartialEq for Transform
Auto Trait Implementations
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more