Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

l3kn/generative_cfg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generative Art with Context-Free Grammars

Framework for exploring (graphical) interpretations of context free grammars (CFGs).

https://www.leonrische.me/pages/images/generative_art_with_cfgs/flower4_03.svg

For an introduction into the theory behind CFGs and a few usage examples, see Generative Art with Context-Free Grammars.

Core Concepts

Grammar
A collection of terminals, non-terminals and production rules. Terminals are implemented as anonymous functions, non-terminals as strings.
State
An object that is passed to each of the (lambda) terminals. A graphics turtle “state” is included.
Backend
Implements conversion form a state to some output format. A backend for generating .svg images is included.

Getting Started

git clone https://github.com/l3kn/generative_cfg
cd generative_cfg
python setup.py install

Then the library can be imported using import generative_cfg.

An easy way to get started is to modify and extend one of the example files in examples/.