Context Free Art:About

What is this thing?
Chris Coyne created a small language for design grammars called CFDG. These grammars are sets of non-deterministic rules to produce images. The images are surprisingly beautiful, often from very simple grammars.

Context Free is a full graphical environment for editing, rendering, and exploring CFDG design grammars.

Features:
 * Simultaneously available for Macintosh, Windows and Posix/Unix.
 * Progressive image update: watch it generate
 * Save generated images in PNG or SVG format.
 * Produce animations
 * Edit grammars and re-render easily.
 * Render very large images (as large as 100 Mega-pixels).
 * Can handle generated images with millions of shapes.
 * Carefully tuned graphics rendering
 * Many built-in examples
 * Automatic checking for updates (Mac only).
 * It's free, as in beer and as in speech.

How do I get started?
First, download and install the program.

Second, run the program and try the things in the Examples menu. Just pick something in that menu, it will open and start generating an image.

Third, choose "Render" from the Render menu, or click the "Render" button (or just type command-R). Most of the rule sets have some random aspect to them and so will generate different images each time.

Fourth, choose lesson from the Examples menu. Read it. Yes, read it, there are lots of comments in the rules. They should explain how rules work. How the heck is it doing that?

Context Free lets you write a set of rules about how to generate an image, and then follows those rules to create a image. The rules define each shape to be made up of other shapes.

The image generation process goes something like this:
 * 1) Start with a just the startshape on the to do list.
 * 2) Now, pick something from the to do list. If the shape is a circle, square, or triangle, then draw it.
 * 3) Otherwise, find the rule for that shape. If a shape has more than one rule, then pick one randomly.
 * 4) Put each shape listed in the rule back on to the to do list. The rule may state that each of these new shapes should be rotated, scaled, relocated and/or brighter than the original shape.
 * 5) Continue from step 2 until the to do list is empty, or everything on it is too small to be seen.

Uh, okay, I'm not sure I got that...
For more answers, help, and discussions, visit the forums.

What is it written in?
The bulk of Context Free is written in C++. It is shared between both Windows and Macintosh versions. The Windows version is built with MFC and Visual C++. The Macintosh version is in a mix of C++ and ObjectiveC, and is built with Xcode. The Posix version uses libpng for rendering and writing PNG files.

All three versions use the incredibly gorgeous Anti-Grain Geometry 2D graphics library by Maxim Shemanarev. It performs very optimized high fidelity anti-aliased drawing that is pixel identical on all three platforms.

The complete source is free (GPL). See the Download page.

Other tools?
We used darcs, a decentralized revision control system for managing the source code. This was our first experience with it and, for the most part, we've been very pleased with how easy it is to set up and use.

You can get the sources via darcs. See the Download page.

Any code worth snagging?
There is a nice system and user interface for managing the random seed used to generate an image. This allows the user to reproduce an image. Steal it, please! (Credit appreciated, of course.)

How did this come to be?
Mark was reading about the recently popular (and Slashdotted) SCIgen - An Automatic CS Paper Generator. He noticed a small reference to Chris' CFDG work in the "related work" section. He was entranced and starting porting immediately. Then John and Mark barely slept for three weeks.

What are context free grammars?
A context free grammar is a description of a language in a set of rules. Each rule says how a single symbol can be expanded into a sequence of other symbols. Those symbols may, in turn, have rules and can be expanded again. Some symbols are terminals and have no rules. A legal sentence in the described language is a sequence of terminal symbols that can be produced starting with the start symbol of the grammar and proceeding via some sequence of expansions.

The process is considered context free because each expansion of a symbol via some rule can be done independently of any of the expansions of other symbols.

In Context Free, the only two terminals are the shapes CIRCLE and SQUARE. Given a starting shape, the program keeps expanding shapes that have rules until all that is left are terminal shapes, which are then drawn. In essence, the rendered images are legal sentences in the language described by the rules file!

For more about the mathematics of grammars, see Context-free grammar in Wikipedia.