SimpleAffine

Struct SimpleAffine 

Source
pub struct SimpleAffine<F: OutputType> {
    pub scale: [F; 2],
    pub to_offset: [F; 2],
    /* private fields */
}
Expand description

This is a simple affine transformation object. Inadvertently it also serves as a type converter F<->I<->i32 It can pan and zoom but not rotate.

Fields§

§scale: [F; 2]

A zoom scale

§to_offset: [F; 2]

The offsets needed to center coordinates of interest on the ‘dest’ coordinate system. i.e. the screen coordinate system.

Implementations§

Source§

impl<F: OutputType> SimpleAffine<F>

Source

pub fn new<I: InputType>( source_aabb: &Aabb2<F>, dest_aabb: &Aabb2<F>, ) -> Result<Self, BvError>

Source

pub fn reverse_transform<I: InputType>( &self, x: F, y: F, ) -> Result<[I; 2], BvError>

transform from destination coordinate system to source coordinate system

Source

pub fn reverse_transform_x<I: InputType>(&self, x: F) -> Result<I, BvError>

transform from destination coordinate system to source coordinate system

Source

pub fn reverse_transform_y<I: InputType>(&self, y: F) -> Result<I, BvError>

transform from dest coordinate system to source coordinate system

Source

pub fn transform(&self, x: F, y: F) -> [F; 2]

transform from source coordinate system to dest coordinate system

Source

pub fn transform_x(&self, x: F) -> F

transform from source coordinate system to dest coordinate system float x coordinate

Source

pub fn transform_y(&self, y: F) -> F

transform from source coordinate system to dest coordinate system float y coordinate

Source

pub fn transform_i<I: InputType>(&self, point: [I; 2]) -> [F; 2]

transform from source coordinate system to dest coordinate system

Source

pub fn transform_f(&self, point: [F; 2]) -> [F; 2]

transform from source coordinate system to dest coordinate system

Source

pub fn transform_p<I: InputType>(&self, point: &Point<I>) -> [F; 2]

transform from source coordinate system to dest coordinate system

Source

pub fn transform_ix<I: InputType>(&self, x: I) -> F

transform from source coordinate system to dest coordinate system integer x coordinate

Source

pub fn transform_iy<I: InputType>(&self, y: I) -> F

transform from source coordinate system to dest coordinate system integer y coordinate

Source

pub fn transform_fx(&self, x: F) -> F

transform from source coordinate system to destination coordinate system float x coordinate

Source

pub fn transform_fy(&self, y: F) -> F

transform from source coordinate system to destination coordinate system float y coordinate

Source

pub fn zoom(&mut self, f: F)

multiply the scale by a factor f

Trait Implementations§

Source§

impl<F: Clone + OutputType> Clone for SimpleAffine<F>

Source§

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

Returns a duplicate 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 + OutputType> Debug for SimpleAffine<F>

Source§

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

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

impl<F: OutputType> Default for SimpleAffine<F>

Source§

fn default() -> Self

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

impl<F: PartialEq + OutputType> PartialEq for SimpleAffine<F>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: OutputType> StructuralPartialEq for SimpleAffine<F>

Auto Trait Implementations§

§

impl<F> Freeze for SimpleAffine<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for SimpleAffine<F>
where F: RefUnwindSafe,

§

impl<F> Send for SimpleAffine<F>
where F: Send,

§

impl<F> Sync for SimpleAffine<F>

§

impl<F> Unpin for SimpleAffine<F>

§

impl<F> UnwindSafe for SimpleAffine<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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

Source§

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

Source§

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.