info = { type = "image", title = "Lightning", category = "btc", author = "BRRRO", version = "1.0", license = "MIT", desc = "Network nodes and a lightning link", api = 33, } local NX = { 10, 31, 53, 18, 45, 33, 9, 55 } local NY = { 14, 8, 16, 42, 47, 28, 52, 38 } local SCENE, BOLT = nil, nil function render() local W, H, FPS = gfx.W, gfx.H, gfx.FPS local floor, sin = math.floor, math.sin if not SCENE then for y = 0, H - 1 do local f = y / H gfx.rect(0, y, W, 1, 48 + 48 * f, 52 + 54 * f, 92 + 64 * f) end BOLT = {} for i = 0, 7 do local j = (i * 3 + 1) % 8 local ax, ay = NX[i + 1], NY[i + 1] local dx, dy = NX[j + 1] - ax, NY[j + 1] - ay local n = math.ceil(math.sqrt(dx * dx + dy * dy)) local p = {} for k = 0, n do local x = floor(ax + dx * k / n + 0.5) local y = floor(ay + dy * k / n + 0.5) gfx.px(x, y, 92, 102, 152) local X = x + floor(2 * sin(k * 1.3) + 0.5) if X >= 0 and X < W and y >= 0 and y < H then p[#p + 1] = X p[#p + 1] = y end end BOLT[i + 1] = p end SCENE = gfx.snapshot(0, 0, W, H) else gfx.blit_rgb(SCENE, 0, 0, W, H) end local p = BOLT[(frame // (FPS * 0.37)) % 8 + 1] for k = 1, #p, 2 do gfx.px(p[k], p[k + 1], 255, 240, 120) end for q = 1, 8 do gfx.rect(NX[q] - 1, NY[q] - 1, 3, 3, 255, 214, 90) gfx.px(NX[q], NY[q], 255, 248, 200) end end