Advertisement
D_Pain

Untitled

Mar 7th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. import turtle
  2.  
  3. turtle.penup()
  4. turtle.goto(-100,-200)
  5. turtle.pendown()
  6.  
  7. #This function draws the fractals with a width of x. i is the number of times I want to divide the sides into another fractal.
  8. def fractals(x,i):
  9.     temp = i - 1
  10.     if(i<=0):
  11.         turtle.forward(x)
  12.     else:
  13.         fractals(x, temp)
  14.         turtle.left(60)
  15.         fractals(x, temp)
  16.         turtle.right(120)
  17.         fractals(x, temp)
  18.         turtle.left(60)
  19.         fractals(x, temp)
  20.        
  21. #This function draws a snowflake using fractals with a width of x. i is the number of time this function will repeat (It should be 6 times). recursionNum is the number of times I want to divide the sides into another fractal.
  22. def fractalsFlake(x,i, recursionNum):
  23.     if(not(i<=0)):
  24.         fractals(x, recursionNum)
  25.         turtle.left(60)
  26.         fractalsFlake(x, i-1, recursionNum)
  27.  
  28. fractalsFlake(10,6, 3)
  29. #This is just used to pause the screen in order to see the end result.
  30. turtle.getscreen()._root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement