Guest User

Untitled

a guest
Mar 1st, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1.  
  2. # cmd > pip install simple_draw
  3. import simple_draw as sd
  4. from random import randint
  5.  
  6. sd.resolution = (1200, 600)
  7.  
  8. def branch(point, angle, length, width):
  9.     if length < 5:
  10.         return
  11.     if length < 20:
  12.         width = 1
  13.     elif length < 100:
  14.         width = 2
  15.     vector = sd.get_vector(start_point=point, angle=angle, length=length, width=width)
  16.     vector.draw()
  17.     point_2 = vector.end_point
  18.     angle_2 = angle - randint(10,40)
  19.     length_2 = length * .75
  20.     branch(point=point_2, angle=angle_2, length=length_2, width=width)
  21.     angle_3 = angle + randint(10,40)
  22.     branch(point=point_2, angle=angle_3, length=length_2, width=width)
  23.  
  24. point_0 = sd.get_point(600, 5)
  25. angle_0 = 90
  26. length_0 = 150
  27.  
  28. branch(point=point_0, angle=angle_0, length=length_0, width=5)
  29.  
  30. sd.pause()
Advertisement
Add Comment
Please, Sign In to add comment