Context Free Art

CFDG HOWTO v2

From Context Free Art

Jump to: navigation, search

A CFDG file consists mostly of several rules for drawing shapes using other shapes. There are a few other optional components and one mandatory component:

Here is an example of all these CFDG file parts:

/* Example CFDG File
This is a block comment. */

// This is one type of line comment
# This is the other type of line comment
 
startshape Foo // There must be a startshape directive
 
include stuff.cfdg // Include rules and paths from stuff.cfdg
 
background { b -1 } // This changes the background to black
 
tile { s 3 4 } // tile the design on a grid with spacing 3 units wide and 4 units high
//size { s 3 4 x 1 y 2} // Size the canvas 3 units wide and 4 units high, centered on (-1, -2)
 
// Let us define a rule for shape Foo that is a white square
// containing a black circle. This will be on a black background.
rule Foo {
SQUARE { b 1 }
CIRCLE {}
Bar { b 1 s 0.5 }
}
 
path Bar {
MOVETO { y 1 }
12* { r (5 * 360 / 13) } {
LINETO { x cos(90 + 5 * 360 / 13)
y sin(90 + 5 * 360 / 13) }
}
CLOSEPOLY {}
FILL { p evenodd }
}

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.

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