Context Free Art
Contents |
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:
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:
For more answers, help, and discussions, visit the forums.
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.
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.
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.)
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.
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.