Skip to main content

ukramaframe

Macro ukramaframe 

Source
macro_rules! ukramaframe {
    (<$TRES:ty, $PRES:ty, $UN:ty>
        $(
            $class:literal $easing:ident [ $($key:literal),* $(,)? ] $duration:literal s ;
        )+
    ) => { ... };
    (<$TRES:ty, $PRES:ty, $UN:ty> $class:literal $easing:ident [ $($key:literal),* $(,)? ] $duration:literal s ) => { ... };
    (<$TRES:ty, $PRES:ty>
        $(
            $class:literal $easing:ident [ $($key:literal),* $(,)? ] $duration:literal s ;
        )+
    ) => { ... };
    (<$TRES:ty, $PRES:ty> $class:literal $easing:ident [ $($key:literal),* $(,)? ] $duration:literal s ) => { ... };
}
Expand description

Creates a compile-time, zero-allocation KramaFrame instance using stack-allocated micro types.

This macro constructs a KramaFrame<UClassList<'static>, UFrameList<'static, N, u32, TRES, PRES>> where all data resides on the stack (no heap allocations). It is intended for scenarios requiring maximum performance and predictability, such as embedded systems or high-frequency animation updates.

The macro requires explicit specification of the timing and progress resolution types (TRES and PRES). All keyframes are initialized with progress: PRES::zero() and the provided animation duration.

§Syntax

ukramaframe!(
    "class_name" EasingFunction [key_id1, key_id2, ..., key_idN] duration s ;
    ...
);
  • <TRES, PRES>: Concrete types implementing TimingResolution and ProgressResolution, respectively.
  • "class_name": A string literal identifying the animation class (must be 'static).
  • EasingFunction: A variant of KeyFrameFunction (e.g., Linear, EaseIn, EaseOut, EaseInOut).
  • [key_id1, key_id2, ...]: A comma-separated list of u32 literal key identifiers. Trailing commas are permitted.
  • duration s: Animation duration in seconds.
    • Integer form: 4 s → internally cast to f32.
    • Floating-point form: 4.0 s → used directly.

Multiple entries are separated by semicolons. A single entry may omit the trailing semicolon.

§Examples

Single entry (integer duration):

use kramaframe::{ukramaframe, TRES16Bits};

let anim = ukramaframe!(<TRES16Bits, i16> "button" EaseIn [1, 2, 3, 4, 5, 6] 4 s);

Single entry (floating-point duration):

use kramaframe::ukramaframe;

let anim = ukramaframe!(<TRES16Bits, i16> "button" EaseIn [1, 2, 3] 4.0 s);

Multiple entries (mixed durations):

use kramaframe::ukramaframe;

let anim = ukramaframe!(<TRES16Bits, i16>
    "menu"   EaseIn   [1, 2, 3]      2 s;
    "button" EaseOut  [4, 5, 6, 7]  1.5 s;
    "header" Linear   [8, 9]       3.0 s;
);

No additional trait imports are required; the macro uses fully qualified paths for TimingResolution::from_sec and ProgressResolution::zero.

This design ensures zero runtime overhead while preserving compile-time type safety and flexibility.