![]() |
||||
| Generative graphics based on probabilistic Context Free Grammars (CFGs) | ||||
| Context Free is a really neat tool to create complex graphics from simple rules. Each graphic has a defined starting point and is then iteratively produced according to expansion rules. The rule syntax and semantics are based on Context Free Grammars (wikipedia), with the addition that you can add probability values for rule execution, which can result in plenty of graphic variations for the same rule set. Plus: you can achieve more interesting and organic results than with deterministic rules. | ||||
![]() |
startshape ROOT
rule ROOT {
TREE{r 90}
}
rule TREE{
BRANCH{s 1.2}
}
rule BRANCH{
DRAWBRANCH{}
BRANCH{x 5 s .999 r 5}
}
rule BRANCH .03{
DRAWBRANCH{}
BRANCH{x 5 s .9 r 90}
BRANCH{x 5 s .9 r -90}
}
rule BRANCH .1{
DRAWBRANCH{}
BRANCH{x 5 s .9 r 180}
}
rule DRAWBRANCH{
CIRCLE{s 1 x 1}
CIRCLE{s 1 x 2}
CIRCLE{s 1 x 3}
CIRCLE{s 1 x 4}
CIRCLE{s 1 x 5}
} |
|||
Some more examples - Each of the four creatures has been
generated by the following set of rules:startshape ROOT
rule ROOT{
NODE{r -20 s .3}
NODE{r 90}
NODE{r 270 s .5}
NODE{r 220 s .3}
}
rule NODE 50{
DRAWNODE{}
NODE{x 1 s .99 r 1 b 0.005}
}
rule NODE 10{
DRAWNODE{}
NODE{x 1 s .99 r -1 b 0.005}
}
rule NODE 10{
DRAWNODE{}
NODE{x 1 s 1.01 b 0.005}
}
rule NODE 1.2{
NODE{x 1 s .99 r 1 b 0.005}
NODE2{}
NODE3{}
}
rule NODE .25{
NODE3{s 2}
}
rule NODE2 50{
DRAWNODE{}
NODE2{x 1 s .99 r -1 b 0.005}
}
rule NODE2 10{
DRAWNODE{}
NODE2{x 1 s .99 r 1 b 0.005}
}
rule NODE2 1.2{
NODE2{x 1 s .99 r -1 b 0.005}
NODE{}
NODE3{}
}
rule NODE2 .25{
NODE3{s 2}
}
rule NODE3{
CIRCLE{s 2 b 0}
}
rule DRAWNODE{
SQUARE{s 1 }
} |
![]() ![]() |
|||
startshape ROOT
rule ROOT {
TREE{r 90}
}
rule TREE{
BRANCH{s 1.2}
}
rule BRANCH{
DRAWBRANCH{}
BRANCH{x 5 s .999 r 5}
}
rule BRANCH .01{
DRAWBRANCH{}
BRANCH{x 5 s .4 r 30}
BRANCH{x 5 s .5 r -90}
}
rule BRANCH .01{
DRAWBRANCH{}
BRANCH{x 5 s .8 r 30}
BRANCH{x 5 s .7 r -90}
}
rule DRAWBRANCH{
CIRCLE{s 3 x 1 b 1}
CIRCLE{s 1 x 2}
CIRCLE{s 1 x 3}
CIRCLE{s 1 x 4}
CIRCLE{s 1 x 5}
} |
![]() |
|||