Created
November 13, 2018 21:07
-
-
Save random-person-001/25574e123bd3a161346eeffd6db758dd to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env/ python3 | |
# although this should probably work on python2 too | |
# | |
# This draws a Maurer Rose, using simple Turtle graphics. | |
# (see https://en.wikipedia.org/wiki/Maurer_rose) | |
# It's cuz they look pretty. | |
# | |
# This is public domain. | |
# | |
import turtle | |
import math | |
import time | |
SCALE = 200 | |
t = turtle.Turtle() | |
t.speed(0) | |
t.hideturtle() | |
def cartesian(r, theta): | |
return r*math.cos(math.radians(theta)), r*math.sin(math.radians(theta)) | |
def r(n, theta): | |
return SCALE * math.sin(n*math.radians(theta)) | |
def reset(): | |
t.pu() | |
t.clear() | |
t.goto(0,0) | |
t.pd() | |
def generate(n, d): | |
out = [] | |
for i in range(362): | |
theta = i * d | |
out.append(cartesian(r(n, theta), theta)) | |
return out | |
def show(l: list): | |
for point in l: | |
t.goto(point[0], point[1]) | |
if __name__ == '__main__': | |
show(generate(2, 29)) | |
time.sleep(5) | |
reset() | |
show(generate(6, 71)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment