Skip to main content

TransformInstance

Struct TransformInstance 

Source
#[repr(C)]
pub struct TransformInstance { pub col0: [f32; 4], pub col1: [f32; 4], pub col2: [f32; 4], pub col3: [f32; 4], }

Fields§

§col0: [f32; 4]§col1: [f32; 4]§col2: [f32; 4]§col3: [f32; 4]

Implementations§

Source§

impl InstanceTransform

Source

pub fn identity() -> Self

Source

pub fn translation(tx: f32, ty: f32) -> Self

Create a 2D translation transform (tx, ty) in pixels.

Each field (col0..col3) stores one column of the GPU mat4x4. Translation lives in col3.

Source

pub fn translation3d(tx: f32, ty: f32, tz: f32) -> Self

Create a 3D translation transform (tx, ty, tz).

Translation is stored in col3.

Source

pub fn scale(sx: f32, sy: f32) -> Self

Create a 2D scale transform with factors (sx, sy).

Source

pub fn scale3d(sx: f32, sy: f32, sz: f32) -> Self

Create a 3D scale transform with factors (sx, sy, sz).

Source

pub fn rotation_z(radians: f32) -> Self

Create a rotation around the Z axis by radians. Positive angles rotate counter-clockwise in screen space.

Source

pub fn rotation_z_deg(degrees: f32) -> Self

Create a rotation around the Z axis by degrees.

Source

pub fn affine_2d(a: f32, b: f32, c: f32, d: f32, tx: f32, ty: f32) -> Self

Create a 2D affine transform from matrix components: [ a c tx ] [ b d ty ] [ 0 0 1 ]

Stored so that col0..col3 map to GPU columns 0..3: col0=[a,b,0,0] col1=[c,d,0,0] col2=[0,0,1,0] col3=[tx,ty,0,1]

Source

pub fn multiply(&self, rhs: &Self) -> Self

Compose two transforms so that self is applied first, then rhs.

This uses left-to-right application order (like CSS/SVG/euclid’s .then()): a.multiply(&b) means “apply a first, then b”.

Note: mathematically this computes rhs × self (not self × rhs), which is what gives us the intuitive left-to-right ordering.

Source

pub fn then(&self, next: &Self) -> Self

Compose two transforms so that self is applied first, then next.

Alias for multiply that mirrors euclid’s Transform3D::then().

let composed = rotation.then(&translation); // rotate first, translate second
Source

pub fn as_cols(&self) -> [[f32; 4]; 4]

Return the 4 columns as an array.

Source

pub fn from_cols(cols: [[f32; 4]; 4]) -> Self

Build from 4 columns.

Source

pub fn desc<'a>() -> VertexBufferLayout<'a>

Trait Implementations§

Source§

impl Clone for InstanceTransform

Source§

fn clone(&self) -> InstanceTransform

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 Debug for InstanceTransform

Source§

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

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

impl Zeroable for InstanceTransform

Source§

fn zeroed() -> Self

Source§

impl Copy for InstanceTransform

Source§

impl Pod for InstanceTransform

Auto Trait Implementations§

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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 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> 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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,