Helper for rendering a spiral.
authorSimon Cross <hodgestar@gmail.com>
Sun, 11 Sep 2016 00:00:12 +0000 (02:00 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 11 Sep 2016 00:00:12 +0000 (02:00 +0200)
misc/spiral.py [new file with mode: 0644]

diff --git a/misc/spiral.py b/misc/spiral.py
new file mode 100644 (file)
index 0000000..6280ddc
--- /dev/null
@@ -0,0 +1,20 @@
+import math
+import json
+
+import pymunk
+
+
+def make_shrub(centre, radial, degrees):
+    radial = radial * (degrees / 80.)
+    c = centre + radial.rotated_degrees(degrees)
+    return [int(round(c.x)), int(round(c.y)), 40]
+
+
+radial = pymunk.Vec2d(40, 0)
+centre = pymunk.Vec2d(512, 400)
+
+obstacles = []
+for d in range(10, 810, 45):
+    obstacles.append(make_shrub(centre, radial, d))
+
+print json.dumps(obstacles)