info = { type = "image", title = "Alps", category = "nature", author = "BRRRO", version = "1.0", license = "MIT", desc = "Three mountain ridges and the sun", api = 33, } local SUN, un = {}, 0 for yy = 4, 14 do local x0, x1 = nil, nil for xx = 44, 55 do local dx, dy = xx - 50, yy - 9 if dx * dx + dy * dy <= 20 then x0 = x0 or xx x1 = xx end end if x0 then SUN[un + 1], SUN[un + 2], SUN[un + 3] = x0, yy, x1 - x0 + 1 un = un + 3 end end local RIDGE = { { 32, 13, 0.06, 3, 130, 150, 180, true }, { 44, 9, 0.10, 7.8, 120, 178, 128, false }, { 55, 6, 0.19, 16.8, 78, 140, 88, false }, } local RSIN, RCOS, BG = nil, nil, nil function render() local W, H, FPS = gfx.W, gfx.H, gfx.FPS local t = frame / FPS local rect = gfx.rect if not RSIN then RSIN, RCOS = {}, {} for r = 1, 3 do local k = RIDGE[r][3] local S, C = {}, {} for x = 0, W - 1 do S[x], C[x] = math.sin(x * k), math.cos(x * k) end RSIN[r], RCOS[r] = S, C end end if not BG then for y = 0, H - 1 do local f = y / H rect(0, y, W, 1, 150 + 66 * f, 192 + 38 * f, 236 + 12 * f) end for i = 1, #SUN, 3 do rect(SUN[i], SUN[i + 1], SUN[i + 2], 1, 255, 238, 164) end BG = gfx.snapshot(0, 0, W, H) else gfx.blit_rgb(BG, 0, 0, W, H) end for r = 1, 3 do local R = RIDGE[r] local a = t * R[4] * R[3] local ca, sa = math.cos(a), math.sin(a) local S, C = RSIN[r], RCOS[r] local base, amp, snow = R[1], R[2], R[8] local x0, hp = 0, nil for x = 0, W do local h = nil if x < W then local v = S[x] * ca + C[x] * sa if v < 0 then v = -v end h = base - math.floor(amp * v + 0.5) end if h ~= hp then if hp then rect(x0, hp, x - x0, H - hp, R[5], R[6], R[7]) if snow then rect(x0, hp, x - x0, 1, 246, 250, 255) rect(x0, hp + 1, x - x0, 1, 236, 243, 250) end end x0, hp = x, h end end end end