pub struct TranslateScale { /* private fields */ }
Expand description

A transformation including scaling and translation.

If the translation is (x, y) and the scale is s, then this transformation represents this augmented matrix:

| s 0 x |
| 0 s y |
| 0 0 1 |

See Affine for more details about the equivalence with augmented matrices.

Various multiplication ops are defined, and these are all defined to be consistent with matrix multiplication. Therefore, TranslateScale * Point is defined but not the other way around.

Also note that multiplication is not commutative. Thus, TranslateScale::scale(2.0) * TranslateScale::translate(Vec2::new(1.0, 0.0)) has a translation of (2, 0), while TranslateScale::translate(Vec2::new(1.0, 0.0)) * TranslateScale::scale(2.0) has a translation of (1, 0). (Both have a scale of 2; also note that the first case can be written 2.0 * TranslateScale::translate(Vec2::new(1.0, 0.0)) as this case has an implicit conversion).

This transformation is less powerful than Affine, but can be applied to more primitives, especially including Rect.

Implementations§

§

impl TranslateScale

pub const fn new(translation: Vec2, scale: f64) -> TranslateScale

Create a new transformation from translation and scale.

pub const fn scale(s: f64) -> TranslateScale

Create a new transformation with scale only.

pub const fn translate(t: Vec2) -> TranslateScale

Create a new transformation with translation only.

pub fn as_tuple(self) -> (Vec2, f64)

Decompose transformation into translation and scale.

pub fn inverse(self) -> TranslateScale

Compute the inverse transform.

Multiplying a transform with its inverse (either on the left or right) results in the identity transform (modulo floating point rounding errors).

Produces NaN values when scale is zero.

pub fn is_finite(&self) -> bool

Is this translate/scale finite?

pub fn is_nan(&self) -> bool

Is this translate/scale NaN?

Trait Implementations§

§

impl Add<TranslateScale> for Vec2

§

type Output = TranslateScale

The resulting type after applying the + operator.
§

fn add(self, other: TranslateScale) -> TranslateScale

Performs the + operation. Read more
§

impl Add<Vec2> for TranslateScale

§

type Output = TranslateScale

The resulting type after applying the + operator.
§

fn add(self, other: Vec2) -> TranslateScale

Performs the + operation. Read more
§

impl AddAssign<Vec2> for TranslateScale

§

fn add_assign(&mut self, other: Vec2)

Performs the += operation. Read more
§

impl Clone for TranslateScale

§

fn clone(&self) -> TranslateScale

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
§

impl Debug for TranslateScale

§

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

Formats the value using the given formatter. Read more
§

impl Default for TranslateScale

§

fn default() -> TranslateScale

Returns the “default value” for a type. Read more
§

impl From<TranslateScale> for Affine

§

fn from(ts: TranslateScale) -> Affine

Converts to this type from the input type.
§

impl<'a> Mul<&'a BezPath> for TranslateScale

§

type Output = BezPath

The resulting type after applying the * operator.
§

fn mul(self, other: &BezPath) -> BezPath

Performs the * operation. Read more
§

impl Mul<BezPath> for TranslateScale

§

type Output = BezPath

The resulting type after applying the * operator.
§

fn mul(self, other: BezPath) -> BezPath

Performs the * operation. Read more
§

impl Mul<Circle> for TranslateScale

§

type Output = Circle

The resulting type after applying the * operator.
§

fn mul(self, other: Circle) -> Circle

Performs the * operation. Read more
§

impl Mul<CubicBez> for TranslateScale

§

type Output = CubicBez

The resulting type after applying the * operator.
§

fn mul(self, other: CubicBez) -> CubicBez

Performs the * operation. Read more
§

impl Mul<Line> for TranslateScale

§

type Output = Line

The resulting type after applying the * operator.
§

fn mul(self, other: Line) -> Line

Performs the * operation. Read more
§

impl Mul<PathEl> for TranslateScale

§

type Output = PathEl

The resulting type after applying the * operator.
§

fn mul(self, other: PathEl) -> PathEl

Performs the * operation. Read more
§

impl Mul<PathSeg> for TranslateScale

§

type Output = PathSeg

The resulting type after applying the * operator.
§

fn mul(self, other: PathSeg) -> PathSeg

Performs the * operation. Read more
§

impl Mul<Point> for TranslateScale

§

type Output = Point

The resulting type after applying the * operator.
§

fn mul(self, other: Point) -> Point

Performs the * operation. Read more
§

impl Mul<QuadBez> for TranslateScale

§

type Output = QuadBez

The resulting type after applying the * operator.
§

fn mul(self, other: QuadBez) -> QuadBez

Performs the * operation. Read more
§

impl Mul<Rect> for TranslateScale

§

type Output = Rect

The resulting type after applying the * operator.
§

fn mul(self, other: Rect) -> Rect

Performs the * operation. Read more
§

impl Mul<RoundedRect> for TranslateScale

§

type Output = RoundedRect

The resulting type after applying the * operator.
§

fn mul(self, other: RoundedRect) -> RoundedRect

Performs the * operation. Read more
§

impl Mul<RoundedRectRadii> for TranslateScale

§

type Output = RoundedRectRadii

The resulting type after applying the * operator.
§

fn mul(self, other: RoundedRectRadii) -> RoundedRectRadii

Performs the * operation. Read more
§

impl Mul<TranslateScale> for TranslateScale

§

type Output = TranslateScale

The resulting type after applying the * operator.
§

fn mul(self, other: TranslateScale) -> TranslateScale

Performs the * operation. Read more
§

impl Mul<TranslateScale> for f64

§

type Output = TranslateScale

The resulting type after applying the * operator.
§

fn mul(self, other: TranslateScale) -> TranslateScale

Performs the * operation. Read more
§

impl MulAssign<TranslateScale> for TranslateScale

§

fn mul_assign(&mut self, other: TranslateScale)

Performs the *= operation. Read more
§

impl Sub<Vec2> for TranslateScale

§

type Output = TranslateScale

The resulting type after applying the - operator.
§

fn sub(self, other: Vec2) -> TranslateScale

Performs the - operation. Read more
§

impl SubAssign<Vec2> for TranslateScale

§

fn sub_assign(&mut self, other: Vec2)

Performs the -= operation. Read more
§

impl Copy for TranslateScale

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> RoundFrom<T> for T

§

fn round_from(x: T) -> T

Performs the conversion.
§

impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,

§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more