info = { type = "image", title = "Sparks", category = "patterns", author = "BRRRO", version = "1.0", license = "MIT", desc = "Gold and blue sparks slowly falling", api = 33, } local N = 40 local X, Y, V, P local COL = { { 90, 150, 255 }, { 255, 196, 64 }, { 230, 230, 245 } } local STEP_HZ = 30 function render() local W, H = gfx.W, gfx.H local t = frame * STEP_HZ // gfx.FPS if not X then X, Y, V, P = {}, {}, {}, {} for i = 1, N do X[i], Y[i] = (i * 37 + 11) % W, (i * 23 + 5) % H V[i], P[i] = 0.12 + ((i * 7) % 5) * 0.05, i * 1.7 end end gfx.clear(8, 8, 20) local sin, rect = math.sin, gfx.rect for i = 1, N do local x = math.floor(X[i] + 2 * sin(t * 0.04 + P[i]) + 0.5) % W local y = math.floor(Y[i] + t * V[i]) % H local k = sin(t * 0.25 + P[i]) > 0 and 1 or 0.55 local c = COL[i % 3 + 1] if ((t // 10) + i) % 2 == 0 then rect(x, y, 2, 1, c[1] * k, c[2] * k, c[3] * k) else rect(x, y, 1, 2, c[1] * k, c[2] * k, c[3] * k) end end end