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

Flag indicating if any property was modified in the current transition. Used to determine if a tween needs to be created.


xChanged: Bool

Flag indicating if the X position was modified in the current transition.


xTween: Tween

Active tween responsible for animating the X position.


xTarget: Float

Target X position value to animate towards.


xStart: Float

Initial X position value when the transition began.


xEnd: Float

Final X position value for the current tween segment.


yChanged: Bool

Flag indicating if the Y position was modified in the current transition.


yTween: Tween

Active tween responsible for animating the Y position.


yTarget: Float

Target Y position value to animate towards.


yStart: Float

Initial Y position value when the transition began.


yEnd: Float

Final Y position value for the current tween segment.


depthChanged: Bool

Flag indicating if the depth was modified in the current transition.


depthTween: Tween

Active tween responsible for animating the depth value.


depthTarget: Float

Target depth value to animate towards.


depthStart: Float

Initial depth value when the transition began.


depthEnd: Float

Final depth value for the current tween segment.


scaleXChanged: Bool

Flag indicating if the X scale was modified in the current transition.


scaleXTween: Tween

Active tween responsible for animating the X scale.


scaleXTarget: Float

Target X scale value to animate towards.


scaleXStart: Float

Initial X scale value when the transition began.


scaleXEnd: Float

Final X scale value for the current tween segment.


scaleYChanged: Bool

Flag indicating if the Y scale was modified in the current transition.


scaleYTween: Tween

Active tween responsible for animating the Y scale.


scaleYTarget: Float

Target Y scale value to animate towards.


scaleYStart: Float

Initial Y scale value when the transition began.


scaleYEnd: Float

Final Y scale value for the current tween segment.


skewXChanged: Bool

Flag indicating if the X skew was modified in the current transition.


skewXTween: Tween

Active tween responsible for animating the X skew.


skewXTarget: Float

Target X skew value to animate towards.


skewXStart: Float

Initial X skew value when the transition began.


skewXEnd: Float

Final X skew value for the current tween segment.


skewYChanged: Bool

Flag indicating if the Y skew was modified in the current transition.


skewYTween: Tween

Active tween responsible for animating the Y skew.


skewYTarget: Float

Target Y skew value to animate towards.


skewYStart: Float

Initial Y skew value when the transition began.


skewYEnd: Float

Final Y skew value for the current tween segment.


anchorXChanged: Bool

Flag indicating if the X anchor was modified in the current transition.


anchorXTween: Tween

Active tween responsible for animating the X anchor point.


anchorXTarget: Float

Target X anchor value to animate towards.


anchorXStart: Float

Initial X anchor value when the transition began.


anchorXEnd: Float

Final X anchor value for the current tween segment.


anchorYChanged: Bool

Flag indicating if the Y anchor was modified in the current transition.


anchorYTween: Tween

Active tween responsible for animating the Y anchor point.


anchorYTarget: Float

Target Y anchor value to animate towards.


anchorYStart: Float

Initial Y anchor value when the transition began.


anchorYEnd: Float

Final Y anchor value for the current tween segment.


rotationChanged: Bool

Flag indicating if the rotation was modified in the current transition.


rotationTween: Tween

Active tween responsible for animating the rotation.


rotationTarget: Float

Target rotation value in degrees to animate towards.


rotationStart: Float

Initial rotation value in degrees when the transition began.


rotationEnd: Float

Final rotation value in degrees for the current tween segment (adjusted for shortest path).


widthChanged: Bool

Flag indicating if the width was modified in the current transition.


widthTween: Tween

Active tween responsible for animating the width.


widthTarget: Float

Target width value to animate towards.


widthStart: Float

Initial width value when the transition began.


widthEnd: Float

Final width value for the current tween segment.


heightChanged: Bool

Flag indicating if the height was modified in the current transition.


heightTween: Tween

Active tween responsible for animating the height.


heightTarget: Float

Target height value to animate towards.


heightStart: Float

Initial height value when the transition began.


heightEnd: Float

Final height value for the current tween segment.


colorChanged: Bool

Flag indicating if the color was modified in the current transition.


colorTween: Tween

Active tween responsible for animating the color using RGB interpolation.


colorTarget: Color

Target color value to animate towards.


colorStart: Color

Initial color value when the transition began.


colorEnd: Color

Final color value for the current tween segment.


alphaChanged: Bool

Flag indicating if the alpha was modified in the current transition.


alphaTween: Tween

Active tween responsible for animating the alpha (opacity).


alphaTarget: Float

Target alpha value (0.0-1.0) to animate towards.


alphaStart: Float

Initial alpha value when the transition began.


alphaEnd: Float

Final alpha value for the current tween segment.


translateXChanged: Bool

Flag indicating if the X translation was modified in the current transition.


translateXTween: Tween

Active tween responsible for animating the X translation.


translateXTarget: Float

Target X translation value to animate towards.


translateXStart: Float

Initial X translation value when the transition began.


translateXEnd: Float

Final X translation value for the current tween segment.


translateYChanged: Bool

Flag indicating if the Y translation was modified in the current transition.


translateYTween: Tween

Active tween responsible for animating the Y translation.


translateYTarget: Float

Target Y translation value to animate towards.


translateYStart: Float

Initial Y translation value when the transition began.


translateYEnd: Float

Final Y translation value for the current tween segment.


transformChanged: Bool

Flag indicating if the transform was modified in the current transition.


transformAssigned: Bool

Flag indicating if a transform instance was directly assigned (vs. modified).


transformAssignedInstance: Transform

The transform instance that was directly assigned, if any.


transformTween: Tween

Active tween responsible for animating the transform using matrix interpolation.


transformTarget: Transform

Target transform matrix to animate towards.


transformStart: Transform

Initial transform matrix when the transition began.


transformEnd: Transform

Final transform matrix for the current tween segment.


transformEndToNull: Bool

Flag indicating if the transform should be set to null at the end of the transition.


transformInTransition: Transform

Temporary transform instance used during the transition to avoid allocations.


offsetXChanged: Bool

Flag indicating if the X offset was modified in the current transition (UI plugin only).


offsetXTween: Tween

Active tween responsible for animating the X offset (UI plugin only).


offsetXTarget: Float

Target X offset value to animate towards (UI plugin only).


offsetXStart: Float

Initial X offset value when the transition began (UI plugin only).


offsetXEnd: Float

Final X offset value for the current tween segment (UI plugin only).


offsetYChanged: Bool

Flag indicating if the Y offset was modified in the current transition (UI plugin only).


offsetYTween: Tween

Active tween responsible for animating the Y offset (UI plugin only).


offsetYTarget: Float

Target Y offset value to animate towards (UI plugin only).


offsetYStart: Float

Initial Y offset value when the transition began (UI plugin only).


offsetYEnd: Float

Final Y offset value for the current tween segment (UI plugin only).


viewWidthChanged: Bool

Flag indicating if the view width was modified in the current transition (UI plugin only).


viewWidthTween: Tween

Active tween responsible for animating the view width (UI plugin only).


viewWidthTarget: Float

Target view width value to animate towards (UI plugin only).


viewWidthStart: Float

Initial view width value when the transition began (UI plugin only).


viewWidthEnd: Float

Final view width value for the current tween segment (UI plugin only).


viewHeightChanged: Bool

Flag indicating if the view height was modified in the current transition (UI plugin only).


viewHeightTween: Tween

Active tween responsible for animating the view height (UI plugin only).


viewHeightTarget: Float

Target view height value to animate towards (UI plugin only).


viewHeightStart: Float

Initial view height value when the transition began (UI plugin only).


viewHeightEnd: Float

Final view height value for the current tween segment (UI plugin only).


isView: Bool

Flag indicating if the entity is a View (UI plugin only). Set during component binding.


bindAsComponent(): Void

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

getEntity(): Entity
Returns
Entity

Metadata

Name Parameters
:hxGen -
: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