Context Free Art
A 2D space can be used to give an illusion of 3D objects, although the illusion is not perfect but in very restricted areas. There are a few tricks to master. Basically:
startshape circles rule circles { CIRCLE { } circles { z -1 s .7 y .7 x -1.5 } circles { z -1 s .7 y .7 x 1.5 } }
In this picture, size ( s .7 ) and the y-coordinate ( y .7 ) produce the illusion in successive recursions. Varying the y increment value ( .7 ) would result in different points of view with respect to the objects. A very small value like .1, would indicate that the viewer eye is on the same level as the objects, for example.
The results get more interesting with variations in color and space, as well as when using more complex objects. In the following picture, a gradual increase in brightness ( b .1 ) produces a mist effect.
startshape forest rule forest { tree { } forest { z -1 s .7 y .7 x -1.5 b .1} forest { z -1 s .7 y .7 x 1.5 b .1} } rule tree { CIRCLE { s .5 1.2 } tree { s .97 y .3 r 3} } rule tree .1 { tree { flip 90 } } rule tree .1 { tree { r 10 } tree { r -30 s .6} }
In the following image, then, there is a hint of a landscape of alternating hills and valleys.
Now our perspective rule ( forest ) has four alternative definitions that produce a non-deterministic outcome. One of the rules is actually empty, in order to terminate some of the branches of recursion ( in the picture these branches appear where the trees end ). Also note the decrease of alpha saturation ( a -.1 )towards the fake perspective.
startshape forest rule forest { moss { y -1 s 12 5 hue 100 sat .6 b .8 } tree { } forest { z -10 x 7 y 1 s .9 a -.1 } forest { z -10 x -5 y 1.2 s .6 a -.1 } } rule forest { moss { y -1 s 12 5 hue 100 sat .6 b .8 } tree { } forest { z -10 x -10 y 1.1 s .9 a -.1} forest { z -10 x 12 y 1.1 s .7 a -.1} } rule forest { forest { y 1 } } // placing the next element higher up gives the eye an illusion of sloping ground rule forest .5 { } rule moss { CIRCLE { } } rule tree { CIRCLE { s .5 1.2 } tree { s .97 y .3 r 3} } rule tree .1 { tree { flip 90 } } rule tree .1 { tree { r 10 } tree { r -30 s .6} }
As the next step, different kinds of objects can be used in place of the uniform trees above. All that is needed is a common "wrapping" that distributes weights as is best ( see the rule forestobject below ).
startshape forest rule forest { moss { y -1 s 12 5 hue 100 sat .6 b .8 } forestobject { } forest { z -10 x 7 y 1 s .9 a -.1 } forest { z -10 x -5 y 1.2 s .6 a -.1 } } rule forest { moss { y -1 s 12 5 hue 100 sat .6 b .8 } forestobject { } forest { z -10 x -10 y 1.1 s .9 a -.1} forest { z -10 x 12 y 1.1 s .7 a -.1} } rule forest { forest { y 1 } } rule forest .5 { } rule moss { CIRCLE { } } rule forestobject { tree { hue 100 } } // make a tree like above rule forestobject { } // leave a piece of ground empty rule forestobject { TRIANGLE { s 3 } } // another kind of object rule tree { CIRCLE { s .5 1.2 } tree { s .97 y .3 r 1 sat .04 b .02} } rule tree .1 { tree { flip 90 } } rule tree .4 { tree { r 10 } tree { r -30 s .6} }
It is clear that this technique has its limitations, but with carefully weighed rules and some determination, quite satisfying pictures can be procured. In spite of occasional errors.
|
|
|
|
| ||||||||||
|
|
|
|
|
It might be inconvenient to give all the power to a recursive perspective rule. There are two techniques to increase your control over the depth of the perspective produced.
In the following picture, a village of some 12 buildings and some trees is portrayed. The houses seem to stand in irregular rows succeeding one another ( though there are some errors on closer look ). Rows it indeed is.
The whole code is not featured here. What we are chiefly interested in is the group of houses and how they are arranged as they are there.
rule village { // draw the village, made of 4* { s .9 y .8 x .5 z -10 } vilrow { } // four rows of houses, decreasing in size and z } // after one another rule vilrow { 3* { x 2.8 y -.1} makebase { z 200 s 1 .4} // each row of houses has three slots to place a house } rule makebase { makebase { y -.1 z .02} } // a slot might be brought "towards the viewer" rule makebase { makebase { x .1} } // or shifted a bit right rule makebase { makebase { x -.1} } // or left rule makebase .8 { makebase { x -.5 } // or sometimes a bit more left makebirch { x 1.5 y .1 z -1 s .1 .3} } // with a tree inserted in the available space // to the right from it rule makebase { house { } } // finally after these optional adjustments, // a house is created
Now it is obvious that this technique works for small villages and the like. Or let's think about an army.
A well ordered group of men. Any problems?
If we try to extend the lines, an obvious hindrance pops up.
The upper corners of the image appear curiously empty. Of course we could think about cropping it out of the picture like in the movies.
A context free grammar can not remember how many units it has used in a rule the previous round, so a special arrangement more sophisticated than that seems really impossible.