function on.resize()
W, H = platform.window:width(), platform.window:height()
X0, Y0 = math.floor(W/2), math.floor(H/2)
UNIT = math.floor(H/2)
end
function on.paint(gc)
local FROM, TO = -math.pi, math.pi
local DT = math.pi/256
local x1, y1 = Lissajous(FROM)
for t = (FROM + DT), TO, DT do
local x2, y2 = Lissajous(t)
gc:drawLine(xy2screen(x1, y1, x2, y2, X0, Y0, UNIT))
x1, y1 = x2, y2
end
end
function Lissajous(ft)
return math.sin(5 * ft), math.cos(7 * ft)
end
function xy2screen(x1, y1, x2, y2, X0, Y0, UNIT)
return (X0 + x1 * UNIT), (Y0 - y1 * UNIT), (X0 + x2 * UNIT), (Y0 - y2 * UNIT)
end