Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- turtle.penup()
- turtle.goto(-100,-200)
- turtle.pendown()
- #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.
- def fractals(x,i):
- temp = i - 1
- if(i<=0):
- turtle.forward(x)
- else:
- fractals(x, temp)
- turtle.left(60)
- fractals(x, temp)
- turtle.right(120)
- fractals(x, temp)
- turtle.left(60)
- fractals(x, temp)
- #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.
- def fractalsFlake(x,i, recursionNum):
- if(not(i<=0)):
- fractals(x, recursionNum)
- turtle.left(60)
- fractalsFlake(x, i-1, recursionNum)
- fractalsFlake(10,6, 3)
- #This is just used to pause the screen in order to see the end result.
- turtle.getscreen()._root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement