Lindenmayer Systems
A Lindenmayer System consists of
an initial string called axiom
a set of rewriting rules
This is an experimental page, where the Lindenmayer Systems can be changed online.
For each system a maximum level is defined. If this value is increased, the complexity of the drawing rises and running time increases too.
Sierpinski curve
Quadratic snowflake variation
var level = 5;
var axiom = '+F';
var rules = {
'F':'F-F+F+F-F',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 90;
var len = 500/Math.pow(3,level);
t.setPos(250,0);
Dragon curve
var level = 8;
var axiom = 'Fl';
var rules = {
'F' : 'F',
'l' : 'l+rF+',
'r' : '-Fl-r',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'l':' ',
'r':' ',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 90;
var len = 500/(level*level);
Islands and lakes
var level = 2;
var axiom = 'F-F-F-F';
var rules = {
'F' : 'F-f+FF-F-FF-Ff-FF+f-FF+F+FF+Ff+FFF',
'f' : 'ffffff',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'f':'f',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 90;
var len = 20/Math.pow(2,level);
Peano curve
var level = 4;
var axiom = 'X';
var rules = {
'F' : 'F',
'X' : 'XFYFX+F+YFXFY-F-XFYFX',
'Y' : 'YFXFY-F-XFYFX+F+YFXFY',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'X':' ',
'Y':' ',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 90;
var len = 500/Math.pow(3,level);
t.setPos(250,-250);
Hexagonal Gosper curve
var level = 3;
var axiom = 'XF';
var rules = {
'F' : 'F',
'X' : 'X+YF++YF-FX--FXFX-YF+',
'Y' : '-FX+YFYF++YF+FX--FX-Y',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'X':' ',
'Y':' ',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 60;
var len = 500/Math.pow(3,level);
t.setPos(250,0);
Plant 1
var level = 3;
var axiom = 'F';
var rules = {
'F' : 'F[+F]F[-F]F',
'[' : '[',
']' : ']',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 25.7;
var len = 500/Math.pow(3,level);
t.setPos(0,-250);
var shrink = 1.0;
t.setProperty({strokeColor:'green',strokeWidth:2});
Plant 2
var level = 4;
var axiom = 'X';
var rules = {
'F' : 'FF',
'X' : 'F-[[X]+X]+F[+FX]-X',
'[' : '[',
']' : ']',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'X':' ',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 22.5;
var len = 800/Math.pow(3,level);
t.setPos(0,-250);
t.setProperty({strokeColor:'green',strokeWidth:2});
Hexagonal kolam
var level = 4;
var axiom = 'X';
var rules = {
'F' : 'F',
'X' : '[-F+F[Y]+F][+F-F[X]-F]',
'Y' : '[-F+F[Y]+F][+F-F-F]',
'[' : '[',
']' : ']',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'X':' ',
'Y':' ',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 60;
var len = 300/(level);
t.setPos(0,-250);
Mango kolam
var level = 5;
var axiom = 'A---A';
var rules = {
'F' : 'F',
'f' : 'f',
'A' : 'f-F+Z+F-fA',
'Z' : 'F-FF-F--[--Z]F-FF-F--F-FF-F--',
'[' : '[',
']' : ']',
'+' : '+',
'-' : '-'
};
var symbols = { 'F':'F',
'f':'f',
'A':' ',
'Z':' ',
'+':'+',
'-':'-',
'[':'[',
']':']'
} ;
var angle = 60;
var len = 100/(level);
Penrose tiling
var level = 2;
var axiom = '[7]++[7]++[7]++[7]++[7]';
var rules = {
'6' : '81++91----71[-81----61]++',
'7' : '+81--91[---61--71]+',
'8' : '-61++71[+++81++91]-',
'9' : '--81++++61[+91++++71]--71',
'1' : '',
'+' : '+',
'-' : '-',
'[' : '[',
']' : ']'
};
var symbols = {
'1':'F',
'6':' ',
'7':' ',
'8':' ',
'9':' ',
'+':'+',
'-':'-',
'[':'[',
']':']'
};
var angle = 36.0;
var len = 100/(level);
t.setProperty({fillcolor:'#abff00'});
References