Struct kurbo::TranslateScale [−][src]
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
[src]
pub const fn new(translation: Vec2, scale: f64) -> TranslateScale
[src]
Create a new transformation from translation and scale.
pub const fn scale(s: f64) -> TranslateScale
[src]
Create a new transformation with scale only.
pub const fn translate(t: Vec2) -> TranslateScale
[src]
Create a new transformation with translation only.
pub fn as_tuple(self) -> (Vec2, f64)
[src]
Decompose transformation into translation and scale.
pub fn inverse(self) -> TranslateScale
[src]
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
[src]
Is this translate/scale finite?
pub fn is_nan(&self) -> bool
[src]
Is this translate/scale NaN?
Trait Implementations
impl Add<TranslateScale> for Vec2
[src]
type Output = TranslateScale
The resulting type after applying the +
operator.
fn add(self, other: TranslateScale) -> TranslateScale
[src]
impl Add<Vec2> for TranslateScale
[src]
type Output = TranslateScale
The resulting type after applying the +
operator.
fn add(self, other: Vec2) -> TranslateScale
[src]
impl AddAssign<Vec2> for TranslateScale
[src]
fn add_assign(&mut self, other: Vec2)
[src]
impl Clone for TranslateScale
[src]
fn clone(&self) -> TranslateScale
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for TranslateScale
[src]
impl Debug for TranslateScale
[src]
impl Default for TranslateScale
[src]
fn default() -> TranslateScale
[src]
impl<'de> Deserialize<'de> for TranslateScale
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl From<TranslateScale> for Affine
[src]
fn from(ts: TranslateScale) -> Affine
[src]
impl<'a> Mul<&'a BezPath> for TranslateScale
[src]
type Output = BezPath
The resulting type after applying the *
operator.
fn mul(self, other: &BezPath) -> BezPath
[src]
impl Mul<BezPath> for TranslateScale
[src]
type Output = BezPath
The resulting type after applying the *
operator.
fn mul(self, other: BezPath) -> BezPath
[src]
impl Mul<Circle> for TranslateScale
[src]
type Output = Circle
The resulting type after applying the *
operator.
fn mul(self, other: Circle) -> Circle
[src]
impl Mul<CubicBez> for TranslateScale
[src]
type Output = CubicBez
The resulting type after applying the *
operator.
fn mul(self, other: CubicBez) -> CubicBez
[src]
impl Mul<Line> for TranslateScale
[src]
type Output = Line
The resulting type after applying the *
operator.
fn mul(self, other: Line) -> Line
[src]
impl Mul<PathEl> for TranslateScale
[src]
type Output = PathEl
The resulting type after applying the *
operator.
fn mul(self, other: PathEl) -> PathEl
[src]
impl Mul<PathSeg> for TranslateScale
[src]
type Output = PathSeg
The resulting type after applying the *
operator.
fn mul(self, other: PathSeg) -> PathSeg
[src]
impl Mul<Point> for TranslateScale
[src]
type Output = Point
The resulting type after applying the *
operator.
fn mul(self, other: Point) -> Point
[src]
impl Mul<QuadBez> for TranslateScale
[src]
type Output = QuadBez
The resulting type after applying the *
operator.
fn mul(self, other: QuadBez) -> QuadBez
[src]
impl Mul<Rect> for TranslateScale
[src]
type Output = Rect
The resulting type after applying the *
operator.
fn mul(self, other: Rect) -> Rect
[src]
impl Mul<RoundedRect> for TranslateScale
[src]
type Output = RoundedRect
The resulting type after applying the *
operator.
fn mul(self, other: RoundedRect) -> RoundedRect
[src]
impl Mul<RoundedRectRadii> for TranslateScale
[src]
type Output = RoundedRectRadii
The resulting type after applying the *
operator.
fn mul(self, other: RoundedRectRadii) -> RoundedRectRadii
[src]
impl Mul<TranslateScale> for TranslateScale
[src]
type Output = TranslateScale
The resulting type after applying the *
operator.
fn mul(self, other: TranslateScale) -> TranslateScale
[src]
impl MulAssign<TranslateScale> for TranslateScale
[src]
fn mul_assign(&mut self, other: TranslateScale)
[src]
impl Serialize for TranslateScale
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl Sub<Vec2> for TranslateScale
[src]
type Output = TranslateScale
The resulting type after applying the -
operator.
fn sub(self, other: Vec2) -> TranslateScale
[src]
impl SubAssign<Vec2> for TranslateScale
[src]
fn sub_assign(&mut self, other: Vec2)
[src]
Auto Trait Implementations
impl RefUnwindSafe for TranslateScale
[src]
impl Send for TranslateScale
[src]
impl Sync for TranslateScale
[src]
impl Unpin for TranslateScale
[src]
impl UnwindSafe for TranslateScale
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,