def main(argv): # check if there are enough arguments if len(argv) < 3: print('usage: %s <lsystem filename> <lsystem filename>' % (argv[0])) exit() # create the lsystem from a file lsys = ls.createLsystemFromFile(argv[1]) # build the lsystem string with 3 iterations lstr = ls.buildString(lsys, 3) dist = float(10) angle = float(90) # draw the abstract1 turtle.tracer(False) nonabstract(lstr, -100, -100, dist, angle) # create the lsystem from a file lsys = ls.createLsystemFromFile(argv[2]) # build the lsystem string with 3 iterations lstr = ls.buildString(lsys, 4) dist = float(3) angle = float(25) # draw the abstract2 turtle.tracer(False) nonabstract(lstr, 100, -200, dist, angle) # wait it.hold()
def tree1(argv, x, y): lsys_filename1 = argv[1] lsys1 = ls.createLsystemFromFile(lsys_filename1) print lsys1 num_iter1 = int(3) dist = float(5) angle1 = float(22) s1 = ls.buildString(lsys1, num_iter1) #draw lsystem1 '''this is my first lsystem with filename mysystem1.txt with 3 iterations and with angle = 45 dist = 10''' turtle.tracer(False) turtle.speed(50000000) turtle.up() turtle.goto(0, 0) turtle.goto(x, y) turtle.down() turtle.pencolor('Brown') it.drawString(s1, dist, angle1) # wait and update turtle.update()
def sun(argv): lsys_filename3 = argv[3] lsys3 = ls.createLsystemFromFile(lsys_filename3) print lsys3 num_iter3 = int(3) dist = 5 angle3 = float(120) s3 = ls.buildString(lsys3, num_iter3) #draw lsystem3 '''this is my third lsystem with filename mysystem3.txt with 3 iterations and with angle = 45 dist = 10''' turtle.up() turtle.goto(0, 0) turtle.goto(300, 200) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Red') it.drawString(s3, dist, angle3) # wait and update turtle.update()
def tree2(argv, x, y): lsys_filename2 = argv[2] lsys2 = ls.createLsystemFromFile(lsys_filename2) print lsys2 num_iter2 = int(3) dist = float(5) angle2 = float(30) s2 = ls.buildString(lsys2, num_iter2) #draw lsystem2 '''this is my second lsystem with filename mysystem2.txt with 5 iterations and with angle = 120 dist = 10''' turtle.up() turtle.goto(0, 0) turtle.goto(x, y) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('White') it.drawString(s2, dist, angle2) # wait and update turtle.update()
def main(argv): ''' Draws something in the turtle window using the L system that is in a file that is entered on the command line. The second and third input is respectively what distance the turtle should go forward and the angle the turtle should turn. ''' if len(argv) < 4: print 'usage: %s <lsystem filename> <distance> <angle>' % (argv[0]) exit() lsys = ls.createLsystemFromFile( argv[1] ) lstr = ls.buildString( lsys, 3 ) dist = float( argv[2] ) angle = float( argv[3] ) turtle.tracer(False) turtle.left(90) drawString( lstr, dist, angle ) hold()
def main(argv): '''creates a set of 9 trees based on a lsystem in a 3x3 grid.''' # check if there are enough arguments if len(argv) < 1: print "Usage : python grid.py <in_filename>" exit() lsys_filename = argv[1] # create the lsystems from a file lsys = ls.createLsystemFromFile( lsys_filename ) x = [-200, 0, 200] y = [100, -150, -350] iters = [1, 2, 3] angles = [22, 46, 60] dist = 10 for c in range( len(iters)): for r in range( len(iters)): turtle.up() turtle.speed(300) turtle.goto(x[c], y[r]) turtle.setheading(0) turtle.left(90) s = ls.buildString( lsys, iters[c] ) turtle.down() it.drawString( s, dist, angles[r] ) # wait and update turtle.update() it.hold()
def grid(key, x, y, scale): # create the lsystem from a file lsys = ls.createLsystemFromFile(key) # build the lsystem string with i iterations for i in range(3): lstr = ls.buildString(lsys, i + 1) for j in [22, 46, 60]: angle = float(j) oldheading = turtle.heading() turtle.up() turtle.goto(x, y) turtle.down() turtle.right(270) turtle.color(0.5, 0.6, 0.8) turtle.width(2) it.drawString(lstr, scale * 0.75, angle) turtle.setheading(oldheading) y = y - scale * 30 y = y + scale * 90 x = x + scale * 30 return
def tree1(argv, x, y): lsys_filename1 = argv[1] lsys1 = ls.createLsystemFromFile( lsys_filename1 ) print lsys1 num_iter1 = int( 3 ) dist = float( 5 ) angle1 = float( 22 ) s1 = ls.buildString( lsys1, num_iter1 ) #draw lsystem1 '''this is my first lsystem with filename mysystem1.txt with 3 iterations and with angle = 45 dist = 10''' turtle.tracer(False) turtle.speed(50000000) turtle.up() turtle.goto(0,0) turtle.goto(x, y) turtle.down() turtle.pencolor('White') it.drawString( s1, dist, angle1 ) # wait and update turtle.update()
def sun(argv): lsys_filename3 = argv[3] lsys3 = ls.createLsystemFromFile( lsys_filename3 ) print lsys3 num_iter3 = int( 3 ) dist = 5 angle3 = float( 120 ) s3 = ls.buildString( lsys3, num_iter3 ) #draw lsystem3 '''this is my third lsystem with filename mysystem3.txt with 3 iterations and with angle = 45 dist = 10''' turtle.up() turtle.goto(0,0) turtle.goto(300, 200) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Red') it.drawString( s3, dist, angle3 ) # wait and update turtle.update()
def tree2(argv, x, y): lsys_filename2 = argv[2] lsys2 = ls.createLsystemFromFile( lsys_filename2 ) print lsys2 num_iter2 = int( 3 ) dist = float( 5 ) angle2 = float( 30 ) s2 = ls.buildString( lsys2, num_iter2 ) #draw lsystem2 '''this is my second lsystem with filename mysystem2.txt with 5 iterations and with angle = 120 dist = 10''' turtle.up() turtle.goto(0,0) turtle.goto(x,y) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('White') it.drawString( s2, dist, angle2 ) # wait and update turtle.update()
def main(argv): # check if there are enough arguments if len(argv) < 4: print('usage: %s <lsystem filename> <distance> <angle>' % (argv[0])) exit() # create the lsystem from a file lsys = ls.createLsystemFromFile(argv[1]) # build the lsystem string with 3 iterations lstr = ls.buildString(lsys, 3) dist = float(argv[2]) angle = float(argv[3]) # draw the two pairs turtle.tracer(False) pair(lstr, -100, 100, dist, angle) pair(lstr, 100, -100, dist * 0.5, angle) # wait it.hold()
def main(argv): # check if there are enough arguments if len(argv) < 2: print('usage: %s <lsystem filename>' % (argv[0])) exit() # create the lsystem from a file lsys = ls.createLsystemFromFile(argv[1]) # build the lsystem string with 3 iterations lstr = ls.buildString(lsys, 3) dist = float(5) angle = float(25) # draw the abstract1 turtle.tracer(False) abstract(lstr, -200, 100, dist, angle, "red", 0) abstract(lstr, -200, 100, dist, angle, "yellow", 90) abstract(lstr, -200, 100, dist, angle, "blue", 180) abstract(lstr, -200, 100, dist, angle, "green", 270) # wait it.hold()
def main(argv): # check if there are enough arguments if len(argv) < 4: print 'usage: %s <lsystem filename> <distance> <angle>' % (argv[0]) exit() # create the lsystem from a file lsys = ls.createLsystemFromFile( argv[1] ) # build the lsystem string with 3 iterations lstr = ls.buildString( lsys, 3 ) dist = float( argv[2] ) angle = float( argv[3] ) # draw the lsystem turtle.tracer(False) turtle.left(90) it.drawString( lstr, dist, angle ) # wait turtle.update() it.hold()
def main(argv): # check if there are enough arguments if len(argv) < 4: print 'usage: %s <lsystem filename> <distance> <angle>' % (argv[0]) exit() # create the lsystem from a file lsys = ls.createLsystemFromFile(argv[1]) # build the lsystem string with 3 iterations lstr = ls.buildString(lsys, 3) dist = float(argv[2]) angle = float(argv[3]) # draw the lsystem turtle.tracer(False) turtle.left(90) it.drawString(lstr, dist, angle) # wait turtle.update() it.hold()
def main(argv): # check if there are enough arguments if len(argv) < 10: print "Usage : python abstract.py 3*<in_filename> 3*<num_iterations>" exit() # assign lsys_filenames to command line filename arguments lsys_filename1 = argv[1] lsys_filename2 = argv[2] lsys_filename3 = argv[3] # create the lsystems from a file lsys1 = ls.createLsystemFromFile( lsys_filename1 ) lsys2 = ls.createLsystemFromFile( lsys_filename2 ) lsys3 = ls.createLsystemFromFile( lsys_filename3 ) print lsys1 print lsys2 print lsys3 # assign num_interations to command line number arguments num_iter1 = int( argv[4] ) num_iter2 = int( argv[5] ) num_iter3 = int( argv[6] ) # build the lsystem string with given number of iterations s1 = ls.buildString( lsys1, num_iter1 ) s2 = ls.buildString( lsys2, num_iter2 ) s3 = ls.buildString( lsys3, num_iter3 ) print s1 print s2 print s3 # assign distances and angles to given command line inputs dist = float( argv[7] ) angle1 = float( argv[8] ) angle2 = float( argv[9] ) angle3 = float( argv[10] ) # draw the lsystems #draw lsystem1 '''this is my first lsystem with filename mysystem1.txt with 3 iterations and with angle = 45 dist = 10''' turtle.tracer(False) turtle.up() turtle.goto(-400, 0) turtle.down() turtle.left(90) turtle.pencolor('Green') it.drawString( s1, dist, angle1 ) #draw lsystem2 '''this is my second lsystem with filename mysystem2.txt with 5 iterations and with angle = 120 dist = 10''' turtle.up() turtle.goto(0,0) turtle.goto(0,0) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Red') it.drawString( s2, dist, angle2 ) #draw lsystem3 '''this is my third lsystem with filename mysystem3.txt with 3 iterations and with angle = 45 dist = 10''' turtle.up() turtle.goto(0,0) turtle.goto(300,-100) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Blue') it.drawString( s3, dist, angle3 ) # wait and update turtle.update() it.hold()
def main(argv): # check if there are enough arguments if len(argv) < 10: print "Usage : python abstract.py 3*<in_filename> 3*<num_iterations>" exit() # assign lsys_filenames to command line filename arguments lsys_filename1 = argv[1] lsys_filename2 = argv[2] lsys_filename3 = argv[3] # create the lsystems from a file lsys1 = ls.createLsystemFromFile(lsys_filename1) lsys2 = ls.createLsystemFromFile(lsys_filename2) lsys3 = ls.createLsystemFromFile(lsys_filename3) print lsys1 print lsys2 print lsys3 # assign num_interations to command line number arguments num_iter1 = int(argv[4]) num_iter2 = int(argv[5]) num_iter3 = int(argv[6]) # build the lsystem string with given number of iterations s1 = ls.buildString(lsys1, num_iter1) s2 = ls.buildString(lsys2, num_iter2) s3 = ls.buildString(lsys3, num_iter3) print s1 print s2 print s3 # assign distances and angles to given command line inputs dist = float(argv[7]) angle1 = float(argv[8]) angle2 = float(argv[9]) angle3 = float(argv[10]) # draw the lsystems #draw lsystem1 '''this is my first lsystem with filename mysystem1.txt with 3 iterations and with angle = 45 dist = 10''' turtle.tracer(False) turtle.up() turtle.goto(-400, 0) turtle.down() turtle.left(90) turtle.pencolor('Green') it.drawString(s1, dist, angle1) #draw lsystem2 '''this is my second lsystem with filename mysystem2.txt with 5 iterations and with angle = 120 dist = 10''' turtle.up() turtle.goto(0, 0) turtle.goto(0, 0) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Red') it.drawString(s2, dist, angle2) #draw lsystem3 '''this is my third lsystem with filename mysystem3.txt with 3 iterations and with angle = 45 dist = 10''' turtle.up() turtle.goto(0, 0) turtle.goto(300, -100) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Blue') it.drawString(s3, dist, angle3) # wait and update turtle.update() it.hold()