VisualTransition

Entityceramic.VisualTransition (Class)
Implements: Component

A component that enables smooth property transitions for Visual objects.

VisualTransition provides a declarative API for animating multiple visual properties simultaneously with automatic interpolation and easing. It handles the complexity of managing multiple concurrent tweens while providing a clean, chainable interface.

Key features:

  • Animate multiple properties in a single transition
  • Automatic handling of transform interpolation
  • Smart rotation with shortest-path calculation
  • Property change detection to avoid unnecessary tweens
  • Support for custom easing per transition
  • "Eager" mode for immediate first-frame updates

Example usage:

// Using the static extension method
myVisual.transition(EASE_IN_OUT, 0.5, props -> {
    props.x = 200;
    props.y = 100;
    props.scale(2.0);
    props.alpha = 0.5;
    props.rotation = 180;
});

// Or as a component
var transition = new VisualTransition(ELASTIC_EASE_OUT, 0.3);
myVisual.component('transition', transition);

transition.run(null, 0.5, props -> {
    props.pos(100, 200);
    props.size(300, 200);
});

Supported properties:

  • Position: x, y, pos()
  • Size: width, height, size()
  • Scale: scaleX, scaleY, scale()
  • Rotation: rotation (with shortest path)
  • Transform: transform, translateX/Y, skewX/Y
  • Appearance: alpha, color
  • Anchor: anchorX, anchorY, anchor()
  • Depth: depth
  • View properties (when UI plugin is enabled)

Static Members

transition(visual: Visual, ?easing: Anonymous, duration: Float, cb: Function): Null<Tween>

Static extension method to run a transition on any Visual.

Creates a transition component if needed and runs the transition. This is the most convenient way to use transitions:

myVisual.transition(EASE_OUT, 0.5, props -> {
    props.x = 100;
    props.alpha = 0;
});
Name Type Default Description
visual Visual The visual to transition
easing Anonymous (optional) Optional easing function
duration Float Duration in seconds
cb Function Callback to set target property values
Returns Description
Null<Tween> The tween instance, or null if no properties changed

eagerTransition(visual: Visual, ?easing: Anonymous, duration: Float, cb: Function): Null<Tween>

Static extension method to run an eager transition on any Visual.

Same as transition() but updates on the first frame.

Name Type Default Description
visual Visual The visual to transition
easing Anonymous (optional) Optional easing function
duration Float Duration in seconds
cb Function Callback to set target property values
Returns Description
Null<Tween> The tween instance, or null if no properties changed

Instance Members

entity: Visual

The Visual entity this transition component is attached to. Set automatically when used as a component.


easing: Anonymous

Default easing function for transitions. Can be overridden per transition in run() or eagerRun().


duration: Float

Default duration for transitions in seconds. Can be overridden per transition in run() or eagerRun().


initializerName: String

run(?easing: Anonymous, duration: Float, cb: Function): Null<Tween>

Run a transition with the specified properties.

The callback receives a properties object where you can set the target values for the transition. Only properties that change from their current values will be animated.

Name Type Default Description
easing Anonymous (optional) Optional easing function (uses default if null)
duration Float Duration in seconds (uses default if -1)
cb Function Callback to set target property values
Returns Description
Null<Tween> The tween instance, or null if no properties changed

eagerRun(?easing: Anonymous, duration: Float, cb: Function): Null<Tween>

Run an "eager" transition that updates on the first frame.

Same as run() but ensures the visual updates immediately instead of waiting for the next frame. Useful for preventing visual "pops" when starting transitions.

Name Type Default Description
easing Anonymous (optional) Optional easing function (uses default if null)
duration Float Duration in seconds (uses default if -1)
cb Function Callback to set target property values
Returns Description
Null<Tween> The tween instance, or null if no properties changed

destroy(): Void

new(?easing: Anonymous, ?duration: Float = 0.3): Void

Create a new visual transition component.

Name Type Default Description
easing Anonymous (optional) Default easing function for transitions
duration Float 0.3 Default duration in seconds (default: 0.3)

Private Members

anyPropertyChanged: Bool

xChanged: Bool

xTween: Tween

xTarget: Float

xStart: Float

xEnd: Float

yChanged: Bool

yTween: Tween

yTarget: Float

yStart: Float

yEnd: Float

depthChanged: Bool

depthTween: Tween

depthTarget: Float

depthStart: Float

depthEnd: Float

scaleXChanged: Bool

scaleXTween: Tween

scaleXTarget: Float

scaleXStart: Float

scaleXEnd: Float

scaleYChanged: Bool

scaleYTween: Tween

scaleYTarget: Float

scaleYStart: Float

scaleYEnd: Float

skewXChanged: Bool

skewXTween: Tween

skewXTarget: Float

skewXStart: Float

skewXEnd: Float

skewYChanged: Bool

skewYTween: Tween

skewYTarget: Float

skewYStart: Float

skewYEnd: Float

anchorXChanged: Bool

anchorXTween: Tween

anchorXTarget: Float

anchorXStart: Float

anchorXEnd: Float

anchorYChanged: Bool

anchorYTween: Tween

anchorYTarget: Float

anchorYStart: Float

anchorYEnd: Float

rotationChanged: Bool

rotationTween: Tween

rotationTarget: Float

rotationStart: Float

rotationEnd: Float

widthChanged: Bool

widthTween: Tween

widthTarget: Float

widthStart: Float

widthEnd: Float

heightChanged: Bool

heightTween: Tween

heightTarget: Float

heightStart: Float

heightEnd: Float

colorChanged: Bool

colorTween: Tween

colorTarget: Color

colorStart: Color

colorEnd: Color

alphaChanged: Bool

alphaTween: Tween

alphaTarget: Float

alphaStart: Float

alphaEnd: Float

translateXChanged: Bool

translateXTween: Tween

translateXTarget: Float

translateXStart: Float

translateXEnd: Float

translateYChanged: Bool

translateYTween: Tween

translateYTarget: Float

translateYStart: Float

translateYEnd: Float

transformChanged: Bool

transformAssigned: Bool

transformAssignedInstance: Transform

transformTween: Tween

transformTarget: Transform

transformStart: Transform

transformEnd: Transform

transformEndToNull: Bool

transformInTransition: Transform

offsetXChanged: Bool

offsetXTween: Tween

offsetXTarget: Float

offsetXStart: Float

offsetXEnd: Float

offsetYChanged: Bool

offsetYTween: Tween

offsetYTarget: Float

offsetYStart: Float

offsetYEnd: Float

viewWidthChanged: Bool

viewWidthTween: Tween

viewWidthTarget: Float

viewWidthStart: Float

viewWidthEnd: Float

viewHeightChanged: Bool

viewHeightTween: Tween

viewHeightTarget: Float

viewHeightStart: Float

viewHeightEnd: Float

isView: Bool

bindAsComponent(): Void

setEntity(entity: Entity): Void
Name Type
entity Entity

getEntity(): Entity
Returns
Entity

Metadata

Name Parameters
:build ceramic.macros.ComponentMacro.build()
:autoBuild ceramic.macros.ComponentMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()
:allow ceramic.VisualTransitionProperties