Context Free Art

Animation

From Context Free Art

Jump to: navigation, search

Contents

Basics

Long, long ago MtnViewMark decided that the way the image builds up when you click the Render button looked cool, so he added a feature to output the rendering process as a movie. Each primitive shape would start being visible at some frame based on when it was drawn in the rendering process. Shapes would remain visible until the end of the movie.

Now you can explicitly control the lifetime of a shape using time and timescale shape adjustments. The default lifetime for the startshape is [0,1], the shape is born at time 0 and dies at time 1. If a cfdg file does not have any time adjustments then Context Free will auto-generate lifetimes based on rendering time, to emulate the original behavior. When you adjust shape time the two adjustment numbers are added to the birth and death time:

startshape row
 
shape row {
loop 10 [x 1 time 1 1]
CIRCLE [time 0 0.5]
}

This generates ten circles in a row with the following lifetimes [0, 1.5], [1, 2.5], [2, 3.5], [3, 4.5], [4, 5.5], [6, 7.5], [8, 9.5], [9, 10.5], [10, 11.5], and [11, 12.5]. Context Free adds together all of these lifetimes to determine that the total lifetime is [0, 12.5]. When a movie is generated this total lifetime is divided by the frame count to generate frame slices. When each frame is drawn only the shapes whose lifetimes overlap the frame slice are drawn during that frame.

Infinity

If a birth time adjustment of -∞ is set then the descendent shapes will live from the start of the movie until their death time. If a death time adjustment of ∞ is set then the descendent shapes will live from their birth time until the end of the movie. ∞ or -∞ birth and death times are discarded when computing the total lifetime. Only finite birth and death times are added up.

CF::Time

Dynamic sizing of the total lifetime is disabled by assigning a shape adjustment to the CF::Time configuration variable. The total lifetime is set by the time adjustment assigned to CF::Time.

Time Scale

The timescale adjustment is directly analogous to the size adjustment. It causes time adjustments in descendent shapes to be scaled, just like size adjustments cause x and y adjustments in descendent shapes to be scaled.

The frame() and ftime() Functions

The frame() function returns the animation progress in the range of [0,1], zero for the first frame through 1 for the last frame. The ftime() function returns the time of the center of the time slice of the current frame. If a cfdg file contains frame() or ftime() then Context Free radically changes how it outputs movies. Without frame() and ftime() Context Free executes the cfdg file once, generates a sentence of primitive shapes, and manipulates this sentence to generate each frame. When frame() or ftime() is present Context Free executes the cfdg file for each frame, generating a sentence for each frame, and manipulating it to output that one frame. frame() and ftime() can be used to change the way shapes look and the way shape rules are executed. They can also be used to change configuration variables.

When a cfdg file is not being animated frame() and ftime() do not have well defined values. Instead, frame() returns the value assigned to CF::Frame and ftime() returns the value assigned to CF::FrameTime.

Views
Personal tools
Navigation
Toolbox
Powered by MediaWiki
Attribution-Share Alike 2.5
book coverSee our book:
Community of Variation