[−]Struct piet_common::kurbo::TranslateScale
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.
Methods
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.
Trait Implementations
impl From<TranslateScale> for Affine
fn from(ts: TranslateScale) -> Affine
impl Copy for TranslateScale
impl Mul<Rect> for TranslateScale
type Output = Rect
The resulting type after applying the * operator.
fn mul(self, other: Rect) -> Rect
impl Mul<CubicBez> for TranslateScale
type Output = CubicBez
The resulting type after applying the * operator.
fn mul(self, other: CubicBez) -> CubicBez
impl Mul<PathEl> for TranslateScale
type Output = PathEl
The resulting type after applying the * operator.
fn mul(self, other: PathEl) -> PathEl
impl Mul<RoundedRect> for TranslateScale
type Output = RoundedRect
The resulting type after applying the * operator.
fn mul(self, other: RoundedRect) -> RoundedRect
impl Mul<QuadBez> for TranslateScale
type Output = QuadBez
The resulting type after applying the * operator.
fn mul(self, other: QuadBez) -> QuadBez
impl Mul<BezPath> for TranslateScale
type Output = BezPath
The resulting type after applying the * operator.
fn mul(self, other: BezPath) -> BezPath
impl Mul<Circle> for TranslateScale
type Output = Circle
The resulting type after applying the * operator.
fn mul(self, other: Circle) -> Circle
impl Mul<TranslateScale> for TranslateScale
type Output = TranslateScale
The resulting type after applying the * operator.
fn mul(self, other: TranslateScale) -> TranslateScale
impl Mul<Point> for TranslateScale
type Output = Point
The resulting type after applying the * operator.
fn mul(self, other: Point) -> Point
impl<'a> Mul<&'a BezPath> for TranslateScale
type Output = BezPath
The resulting type after applying the * operator.
fn mul(self, other: &BezPath) -> BezPath
impl Mul<Line> for TranslateScale
type Output = Line
The resulting type after applying the * operator.
fn mul(self, other: Line) -> Line
impl Default for TranslateScale
fn default() -> TranslateScale
impl Debug for TranslateScale
impl AddAssign<Vec2> for TranslateScale
fn add_assign(&mut self, other: Vec2)
impl Clone for TranslateScale
fn clone(&self) -> TranslateScale
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl MulAssign<TranslateScale> for TranslateScale
fn mul_assign(&mut self, other: TranslateScale)
impl Add<Vec2> for TranslateScale
type Output = TranslateScale
The resulting type after applying the + operator.
fn add(self, other: Vec2) -> TranslateScale
impl Add<TranslateScale> for Vec2
type Output = TranslateScale
The resulting type after applying the + operator.
fn add(self, other: TranslateScale) -> TranslateScale
impl SubAssign<Vec2> for TranslateScale
fn sub_assign(&mut self, other: Vec2)
impl Sub<Vec2> for TranslateScale
type Output = TranslateScale
The resulting type after applying the - operator.
fn sub(self, other: Vec2) -> TranslateScale
Auto Trait Implementations
impl Sync for TranslateScale
impl Send for TranslateScale
impl Unpin for TranslateScale
impl RefUnwindSafe for TranslateScale
impl UnwindSafe for TranslateScale
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> RoundFrom<T> for T[src]
fn round_from(x: T) -> T[src]
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>, [src]
U: RoundFrom<T>,