lindenmayer.py revision cb359e75a84923b77d31e4f6893f21b5fa04e0b0
'''
Copyright (C) 2005 Aaron Spike, aaron@ekips.org
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
def stripme(s):
return s.strip()
help="number of iteration")
help="angle for turning left")
help="angle for turning right")
help="step size")
help="randomize step")
help="randomize angle")
help="initial state of system")
help="replacement rules")
self.rules = dict([map(stripme, i.split("=")) for i in self.options.rules.upper().split(";") if i.count("=")==1])
for c in string:
if c in 'ABCDEF':
elif c in 'GHIJKL':
elif c == '+':
self.turtle.lt(self.options.langle * (random.normalvariate(1.0, 0.01 * self.options.randomizeangle)))
elif c == '-':
self.turtle.rt(self.options.rangle * (random.normalvariate(1.0, 0.01 * self.options.randomizeangle)))
elif c == '|':
elif c == '[':
elif c == ']':
level_string = ''
for c in rule:
try:
except KeyError:
level_string = level_string + c
else:
level_string = level_string + c
return level_string
s = {'stroke-linejoin': 'miter', 'stroke-width': '1.0px',
'stroke-opacity': '1.0', 'fill-opacity': '1.0',
'stroke': '#000000', 'stroke-linecap': 'butt',
'fill': 'none'}
e = LSystem()
e.affect()