CFDG Documentation

A CFDG file consists mostly of several rules for drawing shapes using other shapes. These shapes can either be primitive shapes (SQUARE, CIRCLE, TRIANGLE, or FILL), or non-primitive shapes (which must have there own rules somewhere). A shape's rule can even refer back to the shape itself (a recursive shape definition). This can lead to interesting fractal shapes. A shape can even have more than one rule: every time the shape is executed one of its rules is picked at random. A cfdg file can also contain path declarations, which declare new primitive shapes.

There are three ways to view the output of a cfdg file: as a bitmap, as a vector image, and as a movie. Bitmap output is simply saving the image on the screen to a file. The vector form of the cfdg file can be saved as an SVG file and then manipulated by vector graphics programs. Context Free can output an animation of a cfdg file as a QuickTime video. Cfdg can save it as a series of frame bitmaps.

There are a few other optional components and one mandatory component:
 * A mandatory startshape directive that tells Context Free/CFDG what shape to start with. There must be at least one startshape. If there is more than one then the first one is the one that is used. The startshape can either be at the top level or in an imported cfdg file.
 * variable declarations, which declare a value and binds a name to it
 * configuration declarations, which modify the behavior of Context Free/cfdg
 * function declarations, which declare new numeric functions
 * shape declarations, which provide rules for drawing shapes
 * path declarations, which create new primitive shapes
 * import directives, which direct Context Free/cfdg to insert another CFDG file at the current position. There can be more than one import directives and imported files can import other files.
 * Comment lines that describe how the CFDG file works. Context Free/CFDG supports C-style block comments and C++ and shell-script style line comments.

Here is an example of all these CFDG file parts:


 * shape adjustments are used to pass graphical qualities like size, brightness, saturation, rotation angle, and other qualities (if you wondered what the [ b -1 ] and [ s 3 4 ] mean, that is it)

After getting familiar with the basics, you might want to proceed to the tutorials. If you have trouble remembering all of the details in the cfdg syntax then check out the reference card.

See also the Context Free cans and cannots.