Created
October 30, 2015 15:25
-
-
Save LettError/0d5e4ab5fec6b4c4c116 to your computer and use it in GitHub Desktop.
Draw a spiral in Drawbot.
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 math | |
def segment(x, y, a, d, lw): | |
save() | |
fill(None) | |
stroke(1,1,1) | |
strokeWidth(lw) | |
newPath() | |
moveTo((x,y)) | |
a = math.radians(a) | |
px = x+math.sin(a)*d | |
py = y+math.cos(a)*d | |
lineTo((px,py)) | |
drawPath() | |
restore() | |
return px, py | |
newPage(1000,1000) | |
rect(0,0,1000,1000) | |
translate(500,500) | |
scale(2) | |
x, y = 0,0 | |
steps = 3500 | |
for i in range(steps): | |
x, y = segment(x, y, i**0.5 * 416, 20 * i / steps, 3*i/steps ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment