iamaamir

Fractalpy

Jan 12th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. # Aamir khan
  2.  
  3. from turtle import *
  4.  
  5. def draw(length, angle, level, initial_state, target, replacement, target2, replacement2):
  6.  
  7.     state = initial_state
  8.    
  9.     for counter in range(level):
  10.         state2 = ''
  11.         for character in state:
  12.             if character == target:
  13.                 state2 += replacement
  14.             elif character == target2:
  15.                 state2 += replacement2
  16.             else:
  17.                 state2 += character
  18.         state = state2
  19.        
  20.     # draw
  21.     for character in state:
  22.         if character == 'F':
  23.             forward(length)
  24.         elif character == '+':
  25.             right(angle)
  26.         elif character == '-':
  27.             left(angle)
  28.  
  29.        
  30. if __name__ == '__main__':
  31.    
  32.     draw(5, 90, 10, 'FX', 'X', 'X+YF+', 'Y', '-FX-Y')
Add Comment
Please, Sign In to add comment