Skip to main content

Transformed

Struct Transformed 

Source
pub struct Transformed<T, G> {
    pub inner: T,
    pub transform: G,
}
Expand description

An item paired with an external transform represented by G.

inner retains its own representation while transform controls the extracted geometry. Composition is explicit about order:

Applying an H through ApplyTransform is outer composition and is only available when H embeds into the existing storage type (G: From<H>). Operations never widen the wrapper automatically. Widen explicitly with Into::into when a more general storage type is required.

ⓘ
use ranim_core::{glam::DVec3, prelude::*};

let mut item = ().transformed(Similarity::IDENTITY);
// `Diag` does not embed into `Similarity`; choose `DAffine3` storage first.
item.scale(DVec3::new(2.0, 1.0, 1.0));

Extraction and Aabb calculation convert G to [DAffine3] only at the geometry boundary. Projective transforms remain outside the model-transform system.

Fields§

§inner: T

The item expressed in its own coordinates.

§transform: G

The external transform applied to inner.

Implementations§

Source§

impl<T, G> Transformed<T, G>

Source

pub fn new(inner: T, transform: G) -> Self

Pair inner with transform without converting either value.

Source

pub fn map_inner<U, F>(self, f: F) -> Transformed<U, G>
where F: FnOnce(T) -> U,

Map the wrapped item to a new type, keeping transform unchanged.

Source

pub fn map_transform<H, F>(self, f: F) -> Transformed<T, H>
where F: FnOnce(G) -> H,

Map the transform storage to a new type while keeping inner unchanged.

This is the general form of converting between transform groups — for example widening a placement or checked-narrowing an affine storage back to a subgroup. Lossless upward conversions need no closure at all: Transformed implements From<Transformed<T, X>> for Transformed<T, Y> whenever X embeds into Y, so prefer plain .into() there.

Source

pub fn compose_outer<H>(&mut self, outer: H) -> &mut Self
where G: TransformGroup + From<H>,

Compose outer on the left: transform = outer * transform.

Source

pub fn compose_inner<H>(&mut self, inner: H) -> &mut Self
where G: TransformGroup + From<H>,

Compose inner on the right: transform = transform * inner.

Source

pub fn bake(self) -> T
where T: ApplyTransform<G>,

Bake the stored transform into inner and remove the wrapper.

This method exists only when T directly supports the wrapper’s exact transform representation G.

Trait Implementations§

Source§

impl<T, G> Aabb for Transformed<T, G>
where T: Aabb, G: Clone + Into<DAffine3>,

Source§

fn aabb(&self) -> [DVec3; 2]

Get the Axis-aligned bounding box represent in [<min>, <max>].
Source§

fn aabb_size(&self) -> DVec3

Get the size of the Aabb.
Source§

fn aabb_center(&self) -> DVec3

Get the center of the Aabb.
Source§

impl<T: Alignable, G: Clone> Alignable for Transformed<T, G>

Source§

fn is_aligned(&self, other: &Self) -> bool

Checking if two items are aligned
Source§

fn align_with(&mut self, other: &mut Self)

Aligning two items
Source§

impl<T, G, H> ApplyTransform<H> for Transformed<T, G>
where G: TransformGroup + From<H>,

Source§

fn apply(&mut self, transform: H) -> &mut Self

Bake transform (expressed in world coordinates) into the item’s data, in place.
Source§

impl<T: Clone, G: Clone> Clone for Transformed<T, G>

Source§

fn clone(&self) -> Transformed<T, G>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, G: Debug> Debug for Transformed<T, G>

Source§

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

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

impl<T: Empty, G: TransformGroup> Empty for Transformed<T, G>

Source§

fn empty() -> Self

Create an empty placeholder of a wrapped item.

The inner item contributes T::empty() while the pose is G::identity(): an empty placeholder carries no geometry, so there is no meaningful placement to preserve — identity keeps it neutral for composition until real content is placed on it.

Source§

impl<T, G> Extract for Transformed<T, G>
where T: Extract<Target = CoreItem>, G: Clone + Into<DAffine3>,

Source§

type Target = CoreItem

Extraction target.
Source§

fn extract_into(&self, buf: &mut Vec<Self::Target>)

Append extracted values to buf.
Source§

fn extract(&self) -> Vec<Self::Target>

Extract into a newly allocated vector.
Source§

impl<T: FillColor, G> FillColor for Transformed<T, G>

Source§

fn fill_color(&self) -> AlphaColor<Srgb>

Getting fill color of an item
Source§

fn set_fill_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self

Setting fill color(rgba) of an item
Source§

fn set_fill_opacity(&mut self, opacity: f32) -> &mut Self

Setting fill opacity of an item
Source§

impl<T> From<Transformed<T, Diag>> for Transformed<T, DAffine3>

Source§

fn from(value: Transformed<T, Diag>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Transformed<T, Rigid>> for Transformed<T, Similarity>

Source§

fn from(value: Transformed<T, Rigid>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Transformed<T, Rigid>> for Transformed<T, DAffine3>

Source§

fn from(value: Transformed<T, Rigid>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Transformed<T, Similarity>> for Transformed<T, DAffine3>

Source§

fn from(value: Transformed<T, Similarity>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Transformed<T, Translation>> for Transformed<T, Rigid>

Source§

fn from(value: Transformed<T, Translation>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Transformed<T, Translation>> for Transformed<T, Similarity>

Source§

fn from(value: Transformed<T, Translation>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Transformed<T, Translation>> for Transformed<T, DAffine3>

Source§

fn from(value: Transformed<T, Translation>) -> Self

Converts to this type from the input type.
Source§

impl<T: Interpolatable, G: Interpolatable> Interpolatable for Transformed<T, G>

Source§

fn lerp(&self, target: &Self, t: f64) -> Self

Lerping between values
Source§

impl<T, G> Locate<Transformed<T, G>> for Centroid
where Centroid: Locate<T>, G: Clone + Into<DAffine3>,

Source§

fn locate(&self, target: &Transformed<T, G>) -> DVec3

Locate self on the target
Source§

impl<T: Opacity, G> Opacity for Transformed<T, G>

Source§

fn set_opacity(&mut self, opacity: f32) -> &mut Self

Setting opacity of an item
Source§

impl<T: Partial, G: Clone> Partial for Transformed<T, G>

Source§

fn get_partial(&self, range: Range<f64>) -> Self

Take a partial slice of the wrapped item, keeping the pose.

The range is forwarded to inner, so the partial geometry is taken in the item’s own coordinates, while the stored transform G is cloned unchanged. The wrapper therefore keeps its placement while the visible geometry grows from the slice, which is what create-style animations expect.

Source§

fn get_partial_closed(&self, range: Range<f64>) -> Self

Take a closed partial slice of the wrapped item, keeping the pose.

Like get_partial, but the inner slice is closed so partially shown curves have caps at both ends; the wrapper’s transform is preserved.

Source§

impl<T: PartialEq, G: PartialEq> PartialEq for Transformed<T, G>

Source§

fn eq(&self, other: &Transformed<T, G>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: StrokeColor, G> StrokeColor for Transformed<T, G>

Source§

fn stroke_color(&self) -> AlphaColor<Srgb>

Getting stroke color of an item
Source§

fn set_stroke_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self

Setting stroke color(rgba) of an item
Source§

fn set_stroke_opacity(&mut self, opacity: f32) -> &mut Self

Setting stroke opacity of an item
Source§

impl<T: StrokeWidth, G> StrokeWidth for Transformed<T, G>

Source§

fn stroke_width(&self) -> f32

Get the stroke width
Source§

fn apply_stroke_func( &mut self, f: impl for<'a> Fn(&'a mut [Width]), ) -> &mut Self

Applying stroke width function to an item
Source§

fn set_stroke_width(&mut self, width: f32) -> &mut Self

Setting stroke width of an item
Source§

impl<T: PartialEq, G: PartialEq> StructuralPartialEq for Transformed<T, G>

Auto Trait Implementations§

§

impl<T, G> Freeze for Transformed<T, G>
where T: Freeze, G: Freeze,

§

impl<T, G> RefUnwindSafe for Transformed<T, G>

§

impl<T, G> Send for Transformed<T, G>
where T: Send, G: Send,

§

impl<T, G> Sync for Transformed<T, G>
where T: Sync, G: Sync,

§

impl<T, G> Unpin for Transformed<T, G>
where T: Unpin, G: Unpin,

§

impl<T, G> UnsafeUnpin for Transformed<T, G>
where T: UnsafeUnpin, G: UnsafeUnpin,

§

impl<T, G> UnwindSafe for Transformed<T, G>
where T: UnwindSafe, G: 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> AnyExtractCoreItem for T
where T: Extract<Target = CoreItem> + Any + DynClone,

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)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Color for T
where T: FillColor + StrokeColor + ?Sized,

Source§

fn set_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self

Setting color(rgba) of an item
§

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

Source§

impl<T> Discard for T

Source§

fn discard(&self)

Simply returns ()
Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> RotateTransform for T
where T: ApplyTransform<Rigid> + ?Sized,

Source§

fn rotate_on_axis(&mut self, axis: DVec3, angle: f64) -> &mut T

Rotate the item by a given angle about a given axis.
Source§

fn rotate_on_x(&mut self, angle: f64) -> &mut Self

Rotate the item by a given angle about the X axis.
Source§

fn rotate_on_y(&mut self, angle: f64) -> &mut Self

Rotate the item by a given angle about the Y axis.
Source§

fn rotate_on_z(&mut self, angle: f64) -> &mut Self

Rotate the item by a given angle about the Z axis.
Source§

impl<T> ScaleTransform for T
where T: ApplyTransform<Diag> + ?Sized,

Source§

fn scale(&mut self, scale: DVec3) -> &mut T

Scale at the origin.
Source§

impl<T> ScaleTransformExt for T
where T: ScaleTransform + ?Sized,

Source§

fn calc_scale_ratio(&self, hint: ScaleHint) -> DVec3
where Self: Aabb,

Calculate the scale ratio for a given hint. Read more
Source§

fn scale_to(&mut self, hint: ScaleHint) -> &mut Self
where Self: Aabb,

Scale the item to a given hint (at origin). Read more
Source§

fn scale_to_min(&mut self, hints: &[ScaleHint]) -> &mut Self
where Self: Aabb,

Scale the item to the minimum scale ratio of each axis from the given hints. Read more
Source§

fn scale_to_max(&mut self, hints: &[ScaleHint]) -> &mut Self
where Self: Aabb,

Scale the item to the maximum scale ratio of each axis from the given hints. Read more
Source§

impl<T> ScaleTransformStrokeExt for T

Source§

fn scale_with_stroke(&mut self, scale: DVec3) -> &mut Self

Scale the item with stroke width (at origin).
Source§

fn scale_to_with_stroke(&mut self, hint: ScaleHint) -> &mut Self
where Self: Aabb,

Scale the item to a given hint with stroke width. Read more
Source§

impl<T> ShiftTransform for T

Source§

fn shift(&mut self, offset: DVec3) -> &mut T

Shift the item by a given vector.
Source§

impl<T> ShiftTransformExt for T
where T: ShiftTransform + ?Sized,

Source§

fn with_origin( &mut self, p: impl Locate<Self>, f: impl FnOnce(&mut Self), ) -> &mut Self

Do something with the origin of the item. Read more
Source§

fn move_anchor_to<A>(&mut self, anchor: A, point: DVec3) -> &mut Self
where A: Locate<Self>,

Put anchor at a given point. Read more
Source§

fn move_to(&mut self, point: DVec3) -> &mut Self
where AabbPoint: Locate<Self>,

Put pivot at a given point.
Source§

fn move_next_to<T: Aabb + ?Sized>( &mut self, target: &T, anchor: AabbPoint, ) -> &mut Self
where AabbPoint: Locate<Self>,

Put negative anchor of self on anchor of target
Source§

fn move_next_to_padded<T: Aabb + ?Sized>( &mut self, target: &T, anchor: AabbPoint, padding: f64, ) -> &mut Self
where AabbPoint: Locate<Self>,

Put negative anchor of self on anchor of target, with a distance of padding
Source§

impl<T> StaticAnim for T
where T: StaticAnimRequirement + 'static,

Source§

fn show(&self) -> Paramed<Static<T>>

Show this value.
Source§

fn hide(&self) -> Paramed<Static<T>>

Hide this value.
Source§

impl<T> StaticAnimRequirement for T

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> TransformedExt for T

Source§

fn transformed<G>(self, transform: G) -> Transformed<Self, G>

Return self wrapped with transform stored exactly as G.
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> UniformScaleTransform for T

Source§

fn scale_uniform(&mut self, s: f64) -> &mut T

Scale the item uniformly by s (at origin).
Source§

impl<T> With for T

Source§

fn with(self, f: impl Fn(&mut Self)) -> Self
where Self: Sized,

Mutating a value in place
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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