Skip to content

Animations

Overview

Maverick AI animations are command-driven from the client and executed on-board by the glasses render engine.

Main building blocks:

  • M2Animator - one animator instance per drawable + animation type
  • AnimatorType - what property is animated
  • AnimatorRepeat - repeat behavior (None, Repeat, RepeatBack)
  • IM2AnimatorCallback - started/stopped/failed events
  • M2AnimationsChain - sequence/parallel orchestration

How animations work on board

  1. App creates drawables and adds them to screen/panel.
  2. App configures an animator with the target property, duration, and repeat mode.
  3. App starts animator (anim.start()).
  4. SDK sends animator create/params commands once to glasses.
  5. Glasses OS advances animation every render tick on-device.
  6. App receives callbacks; app may stop/restart/change other objects.

This avoids per-frame animation streaming from phone and keeps motion smooth even when transport bandwidth is limited.

Animation families (AnimatorType)

  • Position/size: X, Y, Width, Height
  • Opacity/color: Alpha, Red, Green, Blue
  • Shape params: RadiusX, RadiusY, A0 (arc start angle), A1 (arc end angle), PenSize
  • Text/sprite: ScaleFont, Sprite
  • Matrix transforms: MatrixScale, MatrixDx, MatrixDy, MatrixDz, MatrixRx, MatrixRy, MatrixRz
  • LOS / AR world movement: WorldVecX, WorldVecY, WorldVecZ
  • Gradient params: GradAlpha, GradRed, GradGreen, GradBlue, GradSize, GradAngle

Start, stop, repeat, callback

Start

Most public usage is:

  1. Build animator through extension function (sets params/callback)
  2. Call start()
val anim = rect.translateXBy(
    durationMillis = 600,
    dx = 120f,
    repeat = AnimatorRepeat.None,
    apply = true,
    callback = object : IM2AnimatorCallback {
        override fun animatorStarted(animator: M2Animator) {}
        override fun animatorStopped(animator: M2Animator) {}
        override fun animatorFailed(animator: M2Animator, err: String) {}
    }
)
anim.start()

Stop

anim.stop() // immediate stop

For repeating animations you can request graceful stop (finish current cycle first):

anim.stop(gracefully = true) {
    // called when stop is completed
}

Repeat modes

  • AnimatorRepeat.None: run once to target
  • AnimatorRepeat.Repeat: loop from start to target
  • AnimatorRepeat.RepeatBack: ping-pong (forward/back)

Common usage examples

Position animation

val move = card.translateYBy(500, dy = -40f, repeat = AnimatorRepeat.None, apply = true)
move.start()

Size animation

val grow = card.animateWidthByPercent(500, percent = 0.2f, apply = true)
grow.start()

LOS / AR movement

val vecAnim = arMesh.animateVecXBy(700, deltaX = 0.4f, apply = true)
vecAnim.start()

Sequence and parallel orchestration

M2AnimationsChain()
    .then { rect.translateXBy(300, 40f, apply = true) }
    .with { rect.translateYBy(300, 20f, apply = true) } // runs in parallel in same step
    .then { rect.translateXBy(300, -40f, apply = true) }
    .start()

Alpha Release

The current alpha release includes a subset of the animation types and helpers. Additional animation capabilities will be added in future releases.

Important behavior notes

  • A drawable keeps one animator per AnimatorType; requesting same type returns/reuses that animator.
  • apply = true means final value is force-applied to drawable state when animation stops.
  • Matrix animators auto-ensure matrix exists before creation (so transform animators can run safely).

See Also