Skip to content

Instantly share code, notes, and snippets.

@LettError
Created October 30, 2015 15:25
Show Gist options
  • Save LettError/0d5e4ab5fec6b4c4c116 to your computer and use it in GitHub Desktop.
Save LettError/0d5e4ab5fec6b4c4c116 to your computer and use it in GitHub Desktop.
Draw a spiral in Drawbot.
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