Glimmr Canvas Animation
version 1/111030 by Erik Temple
Section: Flicker animation tracks
A "flicker" track blinks the targeted object on and off. A flicker can target either of the following:
Basically, each frame, the targeted object will be toggled on or off. Targeting a canvas, of course, toggles the entire canvas and all of the elements displayed on it; moreover, if the canvas is currently displayed in more than one window, it will flicker in all windows where it is showing. If we target a window, then whatever canvas is shown in that window will be blinked on and off.
When targeting a window, we should be sure that there is currently a canvas associated with the window. If no canvas is currently associated with a window, we can bind one to it by setting the window's "associated canvas" property immediately before invoking the animation, e.g.:
now the associated canvas of the graphics-window is the alternate-canvas;
Canvases are toggled by changing the "associated canvas" property of the window to the "g-null-canvas" (empty, at least by default) and back again. The canvas is stored in the "target-canvas" property of the track.
To invoke a flicker animation, we have two options:
animate <track> as a flicker animation targeting <target> at <interval> with a duration of <length> frames, <cycling><randomized>
animate <track> as a flicker animation targeting <target> at <interval>, <randomized>
If we set the "cycling" option, the flicker will continue ad infinitum until we stop it (perhaps using a callback on another animation; see the section on callbacks below). For the second option, which specifies no duration, the animation is automatically set to cycle.
If we set the "randomized" option, then the pattern of flickering will be randomized. Each frame, there is a 50% chance that the object will be toggled.
Targeting a sprite, and cycling endessly:
The neon track is an animation track.
The Neon Sign is a sprite. The display status is g-inactive.
When play begins:
animate the neon track as a flicker animation targeting the Neon Sign at 8 fps.
Targeting a window with a randomized flicker. Since the flicker is randomized, there is no way to ensure that the animation will end with the canvas visible. We can ensure that it will by specifying an animation callback for the track:
The static track is an animation track. The animation-callback is "[@ now the associated canvas of the graphics-window is the target-canvas of the static track]".
The TV canvas is a g-canvas. The background image is Figure of Color Bars. The associated canvas of the graphics-window is the TV canvas.
To display static on the television:
animate the static track as a flicker animation targeting the graphics-window at 8 fps with a duration of 24 frames, randomized.
Note that easing equations have no effect on flicker tracks!