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 typeM2AnimatorType- what property is animatedM2AnimatorRepeat- repeat behavior (None,Repeat,RepeatBack)IM2AnimatorCallback- started/stopped/failed eventsM2AnimationsChain- sequence/parallel orchestration
How animations work on board
- App creates drawables and adds them to screen/panel.
- App configures an animator with the target property, duration, and repeat mode.
- App starts animator (
anim.start()). - SDK sends animator create/params commands once to glasses.
- Glasses OS advances animation every render tick on-device.
- 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 (M2AnimatorType)
- 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:
- Build animator through extension function (sets params/callback)
- Call
start()
val anim = rect.translateXBy(
durationMillis = 600,
dx = 120f,
repeat = M2AnimatorRepeat.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
For repeating animations you can request graceful stop (finish current cycle first):
Repeat modes
M2AnimatorRepeat.None: run once to targetM2AnimatorRepeat.Repeat: loop from start to targetM2AnimatorRepeat.RepeatBack: ping-pong (forward/back)
Common usage examples
Position animation
val move = card.translateYBy(500, dy = -40f, repeat = M2AnimatorRepeat.None, apply = true)
move.start()
Size animation
LOS / AR movement
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()
Accelerating motion (fall, bounce, throw, ease)
Quadratic (accelerating) animators run entirely on the glasses. They need glasses firmware v47 or newer; on older firmware start() fails with animatorFailed.
// Ease into a target X/Y (M2Easing.In speeds up, M2Easing.Out slows down)
card.easeXTo(600, toX = 320f, easing = M2Easing.Out, apply = true).start()
card.easeYTo(600, toY = 120f, easing = M2Easing.In, apply = true).start()
// Gravity: fall to a floor, or bounce back and forth
ball.animateFall(toY = 260f, apply = true).start()
ball.animateBounce(toY = 260f, apply = true).start()
// Throw: horizontal drift plus a gravity fall (returns one animator per axis)
ball.animateThrow(dx = 150f, toY = 260f, apply = true).forEach { it.start() }
M2Motion exposes the glasses frame grid (M2Motion.framesPerSecond, speedPerFrame, accelerationPerFrame) for callers that compute their own speed/acceleration values.
Beta Release
The current beta 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
M2AnimatorType; requesting same type returns/reuses that animator. apply = truemeans 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
- Transformations - 2D and 3D matrix transforms
- Rendering Pipeline - How frames are drawn on the display
- Drawables - The drawable building blocks, and composing your own controls