Cycle<T> Class
Animates a repeating cycle between a high and low value using a given waveform.
The cycling of the animation continues even when the Trigger.Progress
reaches 1. When a trigger is deactivated the cycling will play backwards, possibly beyond reaching Progress=1, until it finds a suitable rest state. This ensure that Cycle
does not produce any jarring switches when the triggers are activated and deactivated.
Example
The below example creates a simple pulsing effect on the panel while it is pressed.
<Panel Color="Blue" ux:Name="panel1" Width="100" Height="100">
<WhilePressed>
<Cycle Target="panel1.Width" Low="80" High="120" Frequency="0.5"/>
</WhilePressed>
</Panel>
By adjusting the Waveform
you can creates animations that wrap-around instead of bouncing back and forth.
<Cycle Target="panel.X" Low="-100" High="100" Waveform="Triangle"/>
The "wrap-around" here is simply the nature of the triangular waveform -- the default waveform is sinusoidal.
Formula
The properties are defined to be a simple interface, but it may be easier to understand see how they all relate in an expression. Given a current time offset the value of the Target
is defined roughly as:
Target.Value = Lerp( Low, High, Easing( Waveform(Time) ) ) * Base + Offset
Low
and High
can only be scalar values. Cycle
checks whether these values cross zero, or one. If they do, it will start at that value, and return to that value when done (this is the default value for ProgressOffset
). This allows a smooth return to rest state in animation.
Modifying Base
and Offset
allows you to use Cycle
with non-scalar values. Though be aware not all combinations of value can provide for a smooth return to the rest state.
Location
- Namespace
- Fuse.Animations
- Package
- Fuse.Animations 2.9.1
Interface of Cycle<T>
Cycle(Property<T>) Constructor uno
Easing : Easing ux
Frequency : double ux
The frequency, in hertz, of the wave: how many times per second the cycle repeats.
FrequencyBack : double ux
The frequency, in hertz, to use when animating back towards the rest position.
High : float ux
The highest scalar value in the cycle.
Low : float ux
The lowest scalar value in the cycle.
Offset : T ux
ProgressOffset : float ux
Specifies the progress when Cycle should start, and defines the rest state. By default this is calculated to be a suitable rest position to avoid animation jerk when it turns on/off.
Restore : CycleRestore ux
How to return the value to the original/rest state when being played backwards/deactivated.
Target : Property<T> uno
The property that is animated.
Waveform : CycleWaveform ux
The shape of the waveform used in the cycle.
Inherited from OpenAnimator
Duration : double ux
HasDuration : bool uno
ResetDuration uno
Inherited from Animator
Delay : double ux
Mixer : IMixer uno
MixOp : MixOp ux
How to mix this animator when there are multiple conflicting animators affecting the target.