Finished what I started last night: A rotatable, resizable polygon generator.

source code
-- phase 5: TOTAL SUCCESS!
engine.name = "TestSine"
function init()
r = 10 -- radius
a = 1 -- angle
p = 3 -- n points
x[p+1] = {}
y[p+1] = {}
x[1] = 64 -- this defines the center of the polygon (x,y)
y[1] = 32
for i = 1, p+1 do
x[i+1] = x[1] + (r * math.cos(a + (i+i-1)*math.pi / p ))
y[i+1] = y[1] + (r * math.sin(a + (i+i-1)*math.pi / p ))
end
-- xy = xy + (10 * cos(radians))
end
function enc(n,d)
if n == 3 then
r = r + d/2
for i = 1, p+1 do
x[i+1] = x[1] + (r * math.cos(a + (i+i-1)*math.pi / p ))
y[i+1] = y[1] + (r * math.sin(a + (i+i-1)*math.pi / p ))
end
print("r:"..r)
redraw()
end
if n == 2 then
a = a + d / (math.pi^math.pi)
for i = 1, p+1 do
x[i+1] = x[1] + (r * math.cos(a + (i+i-1)*math.pi / p ))
y[i+1] = y[1] + (r * math.sin(a + (i+i-1)*math.pi / p ))
end
print("a:"..a)
redraw()
end
if n == 1 then
p = p + d
for i = 1, p+1 do
x[i+1] = x[1] + (r * math.cos(a + (i+i-1)*math.pi / p ))
y[i+1] = y[1] + (r * math.sin(a + (i+i-1)*math.pi / p ))
end
print("p:"..p)
redraw()
end
redraw()
end
function redraw()
screen.aa(0)
screen.line_width(1)
screen.clear()
screen.move(x[2],y[2])
for i = 3, p + 1 do
screen.line(x[i],y[i])
end
screen.line(x[2],y[2])
screen.close()
screen.stroke()
screen.pixel(x[1],y[1]) -- comment this out to get rid of the center point
screen.stroke()
screen.update()
end
COMING SOON:
SHAPES: A visuals based drone-maker/sound processor.
...final name pending
@tehn is this something that would be useful for me to make into a screen utility function?