VisualTransition
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
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 |
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: VisualThe Visual entity this transition component is attached to. Set automatically when used as a component.
Default easing function for transitions. Can be overridden per transition in run() or eagerRun().
duration: FloatDefault duration for transitions in seconds. Can be overridden per transition in run() or eagerRun().
initializerName: StringRun 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 |
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(): VoidCreate 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: BoolFlag indicating if any property was modified in the current transition. Used to determine if a tween needs to be created.
xChanged: BoolFlag indicating if the X position was modified in the current transition.
xTween: TweenActive tween responsible for animating the X position.
xTarget: FloatTarget X position value to animate towards.
xStart: FloatInitial X position value when the transition began.
xEnd: FloatFinal X position value for the current tween segment.
yChanged: BoolFlag indicating if the Y position was modified in the current transition.
yTween: TweenActive tween responsible for animating the Y position.
yTarget: FloatTarget Y position value to animate towards.
yStart: FloatInitial Y position value when the transition began.
yEnd: FloatFinal Y position value for the current tween segment.
depthChanged: BoolFlag indicating if the depth was modified in the current transition.
depthTween: TweenActive tween responsible for animating the depth value.
depthTarget: FloatTarget depth value to animate towards.
depthStart: FloatInitial depth value when the transition began.
depthEnd: FloatFinal depth value for the current tween segment.
scaleXChanged: BoolFlag indicating if the X scale was modified in the current transition.
scaleXTween: TweenActive tween responsible for animating the X scale.
scaleXTarget: FloatTarget X scale value to animate towards.
scaleXStart: FloatInitial X scale value when the transition began.
scaleXEnd: FloatFinal X scale value for the current tween segment.
scaleYChanged: BoolFlag indicating if the Y scale was modified in the current transition.
scaleYTween: TweenActive tween responsible for animating the Y scale.
scaleYTarget: FloatTarget Y scale value to animate towards.
scaleYStart: FloatInitial Y scale value when the transition began.
scaleYEnd: FloatFinal Y scale value for the current tween segment.
skewXChanged: BoolFlag indicating if the X skew was modified in the current transition.
skewXTween: TweenActive tween responsible for animating the X skew.
skewXTarget: FloatTarget X skew value to animate towards.
skewXStart: FloatInitial X skew value when the transition began.
skewXEnd: FloatFinal X skew value for the current tween segment.
skewYChanged: BoolFlag indicating if the Y skew was modified in the current transition.
skewYTween: TweenActive tween responsible for animating the Y skew.
skewYTarget: FloatTarget Y skew value to animate towards.
skewYStart: FloatInitial Y skew value when the transition began.
skewYEnd: FloatFinal Y skew value for the current tween segment.
anchorXChanged: BoolFlag indicating if the X anchor was modified in the current transition.
anchorXTween: TweenActive tween responsible for animating the X anchor point.
anchorXTarget: FloatTarget X anchor value to animate towards.
anchorXStart: FloatInitial X anchor value when the transition began.
anchorXEnd: FloatFinal X anchor value for the current tween segment.
anchorYChanged: BoolFlag indicating if the Y anchor was modified in the current transition.
anchorYTween: TweenActive tween responsible for animating the Y anchor point.
anchorYTarget: FloatTarget Y anchor value to animate towards.
anchorYStart: FloatInitial Y anchor value when the transition began.
anchorYEnd: FloatFinal Y anchor value for the current tween segment.
rotationChanged: BoolFlag indicating if the rotation was modified in the current transition.
rotationTween: TweenActive tween responsible for animating the rotation.
rotationTarget: FloatTarget rotation value in degrees to animate towards.
rotationStart: FloatInitial rotation value in degrees when the transition began.
rotationEnd: FloatFinal rotation value in degrees for the current tween segment (adjusted for shortest path).
widthChanged: BoolFlag indicating if the width was modified in the current transition.
widthTween: TweenActive tween responsible for animating the width.
widthTarget: FloatTarget width value to animate towards.
widthStart: FloatInitial width value when the transition began.
widthEnd: FloatFinal width value for the current tween segment.
heightChanged: BoolFlag indicating if the height was modified in the current transition.
heightTween: TweenActive tween responsible for animating the height.
heightTarget: FloatTarget height value to animate towards.
heightStart: FloatInitial height value when the transition began.
heightEnd: FloatFinal height value for the current tween segment.
colorChanged: BoolFlag indicating if the color was modified in the current transition.
colorTween: TweenActive tween responsible for animating the color using RGB interpolation.
colorTarget: ColorTarget color value to animate towards.
colorStart: ColorInitial color value when the transition began.
colorEnd: ColorFinal color value for the current tween segment.
alphaChanged: BoolFlag indicating if the alpha was modified in the current transition.
alphaTween: TweenActive tween responsible for animating the alpha (opacity).
alphaTarget: FloatTarget alpha value (0.0-1.0) to animate towards.
alphaStart: FloatInitial alpha value when the transition began.
alphaEnd: FloatFinal alpha value for the current tween segment.
translateXChanged: BoolFlag indicating if the X translation was modified in the current transition.
translateXTween: TweenActive tween responsible for animating the X translation.
translateXTarget: FloatTarget X translation value to animate towards.
translateXStart: FloatInitial X translation value when the transition began.
translateXEnd: FloatFinal X translation value for the current tween segment.
translateYChanged: BoolFlag indicating if the Y translation was modified in the current transition.
translateYTween: TweenActive tween responsible for animating the Y translation.
translateYTarget: FloatTarget Y translation value to animate towards.
translateYStart: FloatInitial Y translation value when the transition began.
translateYEnd: FloatFinal Y translation value for the current tween segment.
transformChanged: BoolFlag indicating if the transform was modified in the current transition.
transformAssigned: BoolFlag indicating if a transform instance was directly assigned (vs. modified).
transformAssignedInstance: TransformThe transform instance that was directly assigned, if any.
transformTween: TweenActive tween responsible for animating the transform using matrix interpolation.
transformTarget: TransformTarget transform matrix to animate towards.
transformStart: TransformInitial transform matrix when the transition began.
transformEnd: TransformFinal transform matrix for the current tween segment.
transformEndToNull: BoolFlag indicating if the transform should be set to null at the end of the transition.
transformInTransition: TransformTemporary transform instance used during the transition to avoid allocations.
offsetXChanged: BoolFlag indicating if the X offset was modified in the current transition (UI plugin only).
offsetXTween: TweenActive tween responsible for animating the X offset (UI plugin only).
offsetXTarget: FloatTarget X offset value to animate towards (UI plugin only).
offsetXStart: FloatInitial X offset value when the transition began (UI plugin only).
offsetXEnd: FloatFinal X offset value for the current tween segment (UI plugin only).
offsetYChanged: BoolFlag indicating if the Y offset was modified in the current transition (UI plugin only).
offsetYTween: TweenActive tween responsible for animating the Y offset (UI plugin only).
offsetYTarget: FloatTarget Y offset value to animate towards (UI plugin only).
offsetYStart: FloatInitial Y offset value when the transition began (UI plugin only).
offsetYEnd: FloatFinal Y offset value for the current tween segment (UI plugin only).
viewWidthChanged: BoolFlag indicating if the view width was modified in the current transition (UI plugin only).
viewWidthTween: TweenActive tween responsible for animating the view width (UI plugin only).
viewWidthTarget: FloatTarget view width value to animate towards (UI plugin only).
viewWidthStart: FloatInitial view width value when the transition began (UI plugin only).
viewWidthEnd: FloatFinal view width value for the current tween segment (UI plugin only).
viewHeightChanged: BoolFlag indicating if the view height was modified in the current transition (UI plugin only).
viewHeightTween: TweenActive tween responsible for animating the view height (UI plugin only).
viewHeightTarget: FloatTarget view height value to animate towards (UI plugin only).
viewHeightStart: FloatInitial view height value when the transition began (UI plugin only).
viewHeightEnd: FloatFinal view height value for the current tween segment (UI plugin only).
isView: BoolFlag indicating if the entity is a View (UI plugin only). Set during component binding.
bindAsComponent(): 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 |