Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Localized math functions for faster access
- local mathfloor = math.floor
- local mathsqrt = math.sqrt
- local mathsin = math.sin
- -- Globals
- screen1 = {}
- screen2 = {}
- screen3 = {}
- screenlist = {}
- screencount = 0
- pallet = {}
- plasma = {}
- w = platform.window:width()
- h = platform.window:height()
- tsize = 5
- function on.arrowDown()
- if tsize > 1 then tsize = tsize - 1 end
- end
- function on.arrowUp()
- if tsize < 15 then tsize = tsize + 1 end
- end
- function on.resize(ww,hh)
- timer.stop()
- w,h = ww,hh
- init()
- end
- function on.paint(gc)
- local time = timer.getMilliSecCounter() / 10
- local x,y = 0,0
- while (x < w) do
- while (y < h) do
- local color = pallet[mathfloor((plasma[x][y] + time) % 256)]
- gc:setColorRGB(color.r, color.g, color.b)
- gc:fillRect(x, y, tsize, tsize)
- y = y + tsize
- end
- x = x + tsize
- y = 0
- end
- screencount = (screencount + 1) % 3
- timer.start(0.01)
- end
- function dist(a, b, c, d)
- return mathsqrt(((a - c) * (a - c) + (b - d) * (b - d)))
- end
- function on.timer()
- timer.stop()
- platform.window:invalidate()
- end
- function init()
- pallet = {}
- plasma = {}
- local r,g,b = 0,0,0
- for i = 0, 256 do
- pallet[i] = { r = mathfloor(128.0 + 128 * mathsin(3.1416 * i / 16.0)),
- g = mathfloor(128.0 + 128 * mathsin(3.1416 * i / 128.0)),
- b = 0 }
- end
- for a = 0, w do
- plasma[a] = {}
- for b = 0, h do
- plasma[a][b] = mathfloor(128.0 + (128.0 * mathsin(a / 16.0)) + 128.0 + (128.0 * mathsin(b / 16.0))) / 2
- end
- end
- timer.start(0.01)
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement