Context Free: Grammars as Graphics

I'm pleased to announce the 1.0 release of Context Free: an environment for writing and rendering graphic design grammars for Mac OS X, Windows and Posix/Unix.

In Context Free, you write a context free grammar where the only two terminals are the shapes CIRCLE and SQUARE. Given a starting symbol, the program keeps expanding symbols 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 your grammar!

Context Free is based on Chris Coyne's earlier CFDG, mentioned on LtU in the Fun department.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hmm, surely this loses out to

Hmm, surely this loses out to lsystems in terms of what can be drawn?

It is an lsystem

This is an example of one of the simpler classes of Lindenmayer systems. However, the graphics output quality is quite good! At first glance it appears that this is a result of a different choice for graphics primitives.

It's too bad that they don't have PDF output as an option.

Well, no, it doesn't...

First, I don't think it is a contest - There's plenty of room for both L-systems and CFDG, since neither is a proper superset of the other.

Now, L-Systems in general are rather abstract and could be construed to encompass a lot of things. But, as generally implemented, L-Systems and CFDG have at least one significant difference: In L-Systems, the terminals are commands to turtle graphics, and the fundamental drawing operation is to generate a line or tree (usually fractal.) In CFDG, the terminals are shape primitives (circle or square).

I'm not sure of the theoretic relationship between these approaches, but on a practical level, this means that L-Systems always draw a rather direct representation of the expansion tree, whereas you have the freedom in CFDG to shroud the scaffolding, as it were. My experience is that they produce different classes of images, at least in an artistic sense.

While I've found many gorgeous things drawn with L-Systems - they are almost always in conjunction with one or more other 3D modeling techniques. What I liked about CFDG (and drove to me to create Context Free), was that just this very simple system alone produced very lovely results, with relatively easy rules. Furthermore, it has that hard to define quality of "tweak-ability" - which makes one want to try just one more little modification to the rules again and again!

Really beautiful! I had to

but I had to s/yacc/bison-1.35.yacc/ the Makefile to compile on Debian testing. Newer versions of Bison are drastically non-backwards-compatible for reasons that I don't understand.

very interesting!

I guess I never really thought of CFG as any thing more how it is typically used in comp. sci. (this application is probably going to make me brush up on it again). Is there any proper (published) research done on using CFGs for graphics, audio, etc. (anything other than recognizing languages) ? How about its relationship to fractals? How about applying some sort of 'type system?' ... ok, even my questions don't make any sense anymore...any way, pretty cool!

Combinatorial Structures

CFGs can be used for all sorts of combinatorial structures. See the work of Flajolet and Salvy to see how they can be generated (uniformly and also randomly), enumerated, counted, etc.