-
Notifications
You must be signed in to change notification settings - Fork 9
/
generate-spiral.py
executable file
·40 lines (34 loc) · 1.07 KB
/
generate-spiral.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# ------------------------------------------------------------------
# Copyright (C) 2013 Michael Aschauer
# ------------------------------------------------------------------
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.s
# ------------------------------------------------------------------
import stitchcode
import turtle
stmax = 30
def forward(d):
while d != 0:
def clamp(v):
if (v>stmax):
v = stmax
return v
dx = clamp(d)
turtle.forward(dx)
emb.addStitch(stitchcode.Point(turtle.pos()[0],turtle.pos()[1]))
d -= dx
def f(dist, angle, incr, segs):
for i in range(segs):
forward(dist * (600))
turtle.right(angle)
dist += incr
if __name__ == "__main__":
emb = stitchcode.Embroidery()
turtle.speed(200)
f(.01, 89.5, .01, 150)
emb.translate_to_origin()
emb.save_as_exp("spiral.exp")
emb.save_as_png("spiral.png",True)