Context Free Art – Tutorial 4

The following examples illustrate the use of repetition in Context Free Art.

startshape MyShape

path Line1 {
	MOVETO {x 0 y 0}
	LINETO {x 1 y 0}
	STROKE {width .01}
}

rule MyShape {
	36 * {r 10} Line1 {}
}
Repetition with rotation
startshape MyShape

path Line1 {
	MOVETO {x 0 y 0}
	LINETO {x 1 y 0}
	STROKE {width .01}
}

rule MyShape {
	36 * {r 10 x 0.03} Line1 {}
}
Repetition with rotation and displacement

Context Free Art – Tutorial 3

These exercises cover the use of path in a shape.

startshape MyShape

path Line1 {
	MOVETO {x 0 y 0}
	LINETO {x 1 y 1}
	STROKE {width .01}
}

rule MyShape {
	Line1 {}
}
Line
startshape MyShape

path Line1 {
	MOVETO {x 0 y 0}
	LINETO {x 1 y 1}
	LINETO {x 0 y 1}
	LINETO {x 1 y 0}
	LINETO {x 0 y 0}
	STROKE {width .01}
}

rule MyShape {
	Line1 {}
}
Multiple lines
startshape MyShape

path Line1 {
	MOVETO {x 0 y 0}
	LINETO {x 1 y 0}
	STROKE {width .01}
}

rule MyShape {
	Line1 {r 25}
}
Rotation adjustment

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