Created
December 30, 2015 16:36
-
-
Save fogleman/006e4069348fa163b8ae to your computer and use it in GitHub Desktop.
Dragon Curve with Turtle Graphics (Python)
This file contains 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 turn(i): | |
left = (((i & -i) << 1) & i) != 0 | |
return 'L' if left else 'R' | |
def curve(iteration): | |
return ''.join([turn(i + 1) for i in range(2 ** iteration - 1)]) | |
if __name__ == '__main__': | |
turtle.showturtle() | |
turtle.hideturtle() | |
turtle.speed(0) | |
i = 1 | |
while True: | |
if turn(i) == 'L': | |
turtle.circle(-4, 90, 36) | |
else: | |
turtle.circle(4, 90, 36) | |
i += 1 |
Nice man
not workin
Nice
Amazing man
wow amazing bro
wow!
what the
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice