-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbasicSpiral.lua
More file actions
26 lines (25 loc) · 763 Bytes
/
basicSpiral.lua
File metadata and controls
26 lines (25 loc) · 763 Bytes
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
-- Spiral
function spiral(func, turns, center)
local angles = {}
-- angle vector:
local angle = 0
while angle <= math.pi*2*turns do
table.insert(angles, angle)
angle = angle + math.pi*2/128
end
local x, y, r
local spiralPoints = {}
for i=1, #angles, 1 do
r = func(angles[i])
x = r * math.cos(angles[i]) + center.x
y = r * math.sin(angles[i]) + center.y
table.insert(spiralPoints, Point(x, y))
end
return spiralPoints
end
local spiralFunc = function(angle)
return angle*18/math.pi
end
local center = Point(app.activeSprite.width, app.activeSprite.height)/2
local spiral = spiral(spiralFunc, 3, center)
app.useTool {tool='pencil', points=spiral}