Struct pointy::Transform

source ·
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,

source

pub fn with_translate(tx: F, ty: F) -> Self

Create a new translation transform.

  • tx Amount to translate X.
  • ty Amount to translate Y.
source

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.
source

pub fn with_rotate(th: F) -> Self

Create a new rotation transform.

  • th Angle to rotate coordinates (radians).
source

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).
source

pub fn translate(self, tx: F, ty: F) -> Self

Apply translation to a transform.

  • tx Amount to translate X.
  • ty Amount to translate Y.
source

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.
source

pub fn rotate(self, th: F) -> Self

Apply rotation to a transform.

  • th Angle to rotate coordinates (radians).
source

pub fn skew(self, ax: F, ay: F) -> Self

Apply skew to a transform.

  • ax Angle to skew X-axis (radians).
  • ay Angle to skew Y-axis (radians).

Trait Implementations§

source§

impl<F> Clone for Transform<F>
where F: Float + Clone,

source§

fn clone(&self) -> Transform<F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F> Debug for Transform<F>
where F: Float + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<F> Default for Transform<F>
where F: Float,

source§

fn default() -> Self

Create a new identity transform.

source§

impl<F> Mul<(F, F)> for Transform<F>
where F: Float,

§

type Output = Pt<F>

The resulting type after applying the * operator.
source§

fn mul(self, s: (F, F)) -> Pt<F>

Performs the * operation. Read more
source§

impl<F> Mul<Pt<F>> for Transform<F>
where F: Float,

§

type Output = Pt<F>

The resulting type after applying the * operator.
source§

fn mul(self, s: Pt<F>) -> Pt<F>

Performs the * operation. Read more
source§

impl<F> Mul<Transform<F>> for (F, F)
where F: Float,

§

type Output = Pt<F>

The resulting type after applying the * operator.
source§

fn mul(self, t: Transform<F>) -> Pt<F>

Performs the * operation. Read more
source§

impl<F> Mul<Transform<F>> for Pt<F>
where F: Float,

§

type Output = Pt<F>

The resulting type after applying the * operator.
source§

fn mul(self, t: Transform<F>) -> Self

Performs the * operation. Read more
source§

impl<F> Mul for Transform<F>
where F: Float,

§

type Output = Transform<F>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl<F> MulAssign for Transform<F>
where F: Float,

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl<F> PartialEq for Transform<F>
where F: Float + PartialEq,

source§

fn eq(&self, other: &Transform<F>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F> Copy for Transform<F>
where F: Float + Copy,

source§

impl<F> Eq for Transform<F>
where F: Float + Eq,

source§

impl<F> StructuralEq for Transform<F>
where F: Float,

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.