Struct kurbo::TranslateScale

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

source§

impl TranslateScale

source

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

Create a new transformation from translation and scale.

source

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

Create a new transformation with scale only.

source

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

Create a new transformation with translation only.

source

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

Decompose transformation into translation and scale.

source

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.

source

pub fn is_finite(&self) -> bool

Is this translate/scale finite?

source

pub fn is_nan(&self) -> bool

Is this translate/scale NaN?

Trait Implementations§

source§

impl Add<TranslateScale> for Vec2

§

type Output = TranslateScale

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<Vec2> for TranslateScale

§

type Output = TranslateScale

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl AddAssign<Vec2> for TranslateScale

source§

fn add_assign(&mut self, other: Vec2)

Performs the += operation. Read more
source§

impl Clone for TranslateScale

source§

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

impl Debug for TranslateScale

source§

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

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

impl Default for TranslateScale

source§

fn default() -> TranslateScale

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

impl<'de> Deserialize<'de> for TranslateScale

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<TranslateScale> for Affine

source§

fn from(ts: TranslateScale) -> Affine

Converts to this type from the input type.
source§

impl JsonSchema for TranslateScale

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

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

§

type Output = BezPath

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<BezPath> for TranslateScale

§

type Output = BezPath

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Circle> for TranslateScale

§

type Output = Circle

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<CubicBez> for TranslateScale

§

type Output = CubicBez

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Line> for TranslateScale

§

type Output = Line

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<PathEl> for TranslateScale

§

type Output = PathEl

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<PathSeg> for TranslateScale

§

type Output = PathSeg

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Point> for TranslateScale

§

type Output = Point

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<QuadBez> for TranslateScale

§

type Output = QuadBez

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Rect> for TranslateScale

§

type Output = Rect

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<RoundedRect> for TranslateScale

§

type Output = RoundedRect

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<RoundedRectRadii> for TranslateScale

§

type Output = RoundedRectRadii

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<TranslateScale> for TranslateScale

§

type Output = TranslateScale

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<TranslateScale> for f64

§

type Output = TranslateScale

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl MulAssign<TranslateScale> for TranslateScale

source§

fn mul_assign(&mut self, other: TranslateScale)

Performs the *= operation. Read more
source§

impl Serialize for TranslateScale

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub<Vec2> for TranslateScale

§

type Output = TranslateScale

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl SubAssign<Vec2> for TranslateScale

source§

fn sub_assign(&mut self, other: Vec2)

Performs the -= operation. Read more
source§

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 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.
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.
source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,