Created
March 25, 2015 03:08
-
-
Save pmarkun/44575b7641e8cf36c27b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import turtle | |
| def floor(x,y): | |
| if x > y: | |
| return x | |
| return y | |
| def draw_fern(length1, angle1, length2, angle2, depth): | |
| flip = 1 | |
| for i in range (0, length2): | |
| jonney.left(angle2) | |
| jonney.forward(length1) | |
| if depth > 1: | |
| jonney.left(angle1*flip) | |
| draw_fern(floor((length1/3)-(i/2), 1), angle1*flip,floor(length2-i,1), angle2*flip, depth-1) | |
| jonney.left(180-angle1*flip) | |
| flip = flip * -1 | |
| jonney.left(180) | |
| for i in range(0, length2): | |
| jonney.forward(length1) | |
| jonney.right(angle2) | |
| jonney = turtle.Turtle() | |
| jonney.penup() | |
| jonney.goto(0,-100) | |
| jonney.pendown() | |
| jonney.left(90) | |
| jonney.speed(0) | |
| draw_fern(40,60,8,4,4) | |
| turtle.exitonclick() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment