Context Free Art is a simple art-generation context-free language that uses recursion (among other things) to generate images (and videos). I recently saw a post about it, and I decided to try it out. Then I found a folder in my files from 2013 where I had previously come across it and forgotten all about it.
While more suited to the abstract, it’s possible to create more traditional art with it, as seen in two of the four examples at the bottom.
Here is a sample input to the program:
// Sample input
// two slashes make a comment
// command to build:
// cfdg -s 1920x1080 -m 1000000 sample.cfdg sample.png
// cfdg the command
// -s set size to 1080p
// -m set the maximum number of shapes; helps in case of too much recursion
// [file].cfdg the input file
// [file].png the output image
// Required to kick things off.
startshape Sample
// Make a default background color (random)
CF::Background = [b rand(-0.5,-0.25) sat rand(0.25,0.75) h randint(360)]
// b is brightness; sat is saturation; h is hue
shape Sample {
SQUARE [s 100 x -200]
CIRCLE [s 100]
TRIANGLE [s 100 x 200]
}
// s is size; x is horizontal position
There are three basic shapes available. Can you guess what they are?

And you can make your own shapes, using path
declarations:
path ZA {
MOVETO(-0.5, 0)
LINETO(0, 1)
LINETO(0.5, 0)
ARCTO(-0.5, 0, -1)
CLOSEPOLY()
// STROKE()[]
FILL() []
}
This example path creates a piece of pizza! Notice it has STROKE
commented out. If you want, you can make outlined shapes using that.

Github: MtnViewJohn: context-free
: Wiki has most of the details on how to use the tool, though you can also look at the gallery of the official website (linked above), where users have provided samples that include their source code.
Anyway, just a short writeup. Here’s some pictures I made with it:



