Context Free Art – Tutorial 2

We introduce the use of the rotation parameter for a shape:

startshape MyShape

rule MyShape {
     SQUARE {x -4 r 90}
     SQUARE {x -2 r 70}
     SQUARE {r 50}
     SQUARE {x +2 r 30}
     SQUARE {x +4 r 10}
}


Rotation
   

Context Free Art – Tutorial 1

After we can create different primitive shapes, we start to combine them together. We cannot simply put all the primitive shapes within one single shape rule, like:

startshape MyShape

rule MyShape {
     CIRCLE {}
     TRIANGLE {}
     SQUARE {}
}
Multiple shapes

Every shape command comes with parameters. We work with the translation parameters x and y to move the shape around in the canvas.

startshape MyShape

rule MyShape {
     CIRCLE {x -2}
     TRIANGLE {}
     SQUARE {x 2}
}

Multiple shapes
startshape MyShape

rule MyShape {
     CIRCLE {y 2}
     TRIANGLE {}
     SQUARE {y -2}
}
Multiple shapes

startshape MyShape

rule MyShape {
     CIRCLE {x 2 y 2 size 0.8}
     TRIANGLE {size 2}
     SQUARE {x -2 y -2 size 0.5}
}


Size variation

Context Free Art

To prepare for a new course Evolutionary Graphics in AVA, I am testing the use of various graphical tools. One of them is the Context Free Art. It is a ruled based language to generate complex imagery. It cannot be described as a programming language as it lacks a lot of procedural elements. Its recursive capability makes it a good choice for generative type of graphics.

The Community of Variation book contains the sample of drawings in the gallery.

Community of Variation

The drawing is done by typing a sequence of rules on the left hand panel. Press the ‘Render’ button to generate the graphics.

Main window

Every ‘program’ starts with a startshape keyword. For example, to draw a circle, we can type in the following:

startshape MyShape

rule MyShape {
     CIRCLE {}
}


Circle

To draw a square, type:

startshape MyShape

rule MyShape {
     SQUARE {}
}


Square

To draw a triangle, type:

startshape MyShape

rule MyShape {
     TRIANGLE {}
}


Triangle