info = { type = "image", title = "Window", category = "nature", author = "BRRRO", version = "1.0", license = "MIT", desc = "A winter scene behind the window", api = 33, } local MOON, mn = {}, 0 for yy = -4, 4 do local x0, x1 = nil, nil for xx = -4, 4 do local dx = xx - 1.4 if xx * xx + yy * yy <= 16 and dx * dx + yy * yy > 16 then x0 = x0 or xx x1 = xx end end if x0 then MOON[mn + 1], MOON[mn + 2], MOON[mn + 3] = 13 + x0, 11 + yy, x1 - x0 + 1 mn = mn + 3 end end local LIMB = { { 46, 32, -0.78, -0.72, 10 }, { 46, 30, 0.82, -0.66, 10 }, { 45, 27, -0.66, -0.74, 8 }, { 46, 26, 0.62, -0.78, 8 }, { 45, 23, -0.45, -0.82, 6 }, { 46, 23, 0.50, -0.80, 6 }, { 45, 21, 0, -1, 4 }, } local TREE, tn = {}, 0 for li = 1, #LIMB do local L = LIMB[li] for s = 0, L[5] do local X = math.floor(L[1] + L[3] * s + 0.5) local Y = math.floor(L[2] + L[4] * s + 0.5) TREE[tn + 1], TREE[tn + 2], TREE[tn + 3] = X, Y, false tn = tn + 3 if s >= L[5] - 1 then TREE[tn + 1], TREE[tn + 2], TREE[tn + 3] = X, Y - 1, true tn = tn + 3 end end end TREE[tn + 1], TREE[tn + 2], TREE[tn + 3] = 45, 20, true TREE[tn + 4], TREE[tn + 5], TREE[tn + 6] = 46, 20, true TREE[tn + 7], TREE[tn + 8], TREE[tn + 9] = 45, 21, true local HILL, BG = nil, nil function render() local W, H = gfx.W, gfx.H local t = frame / gfx.FPS local rect, px = gfx.rect, gfx.px if not HILL then HILL = {} local n, x0, hp = 0, 0, nil for x = 0, W do local h = nil if x < W then h = 42 - math.floor(4 * math.sin(x * 0.14) + 0.5) end if h ~= hp then if hp then HILL[n + 1], HILL[n + 2], HILL[n + 3] = x0, x - x0, hp n = n + 3 end x0, hp = x, h end end end if not BG then for y = 0, H - 1 do local f = y / H rect(0, y, W, 1, 150 + 55 * f, 180 + 38 * f, 222 + 16 * f) end for i = 1, #MOON, 3 do rect(MOON[i], MOON[i + 1], MOON[i + 2], 1, 238, 240, 224) end for i = 1, #HILL, 3 do local hy = HILL[i + 2] rect(HILL[i], hy, HILL[i + 1], H - hy, 216, 226, 240) end rect(45, 22, 2, 20, 70, 55, 46) for i = 1, #TREE, 3 do if TREE[i + 2] then px(TREE[i], TREE[i + 1], 228, 234, 244) else px(TREE[i], TREE[i + 1], 70, 55, 46) end end BG = gfx.snapshot(0, 0, W, H) else gfx.blit_rgb(BG, 0, 0, W, H) end for i = 0, 33 do px((i * 23 + t * 24) % W, (i * 37 + t * 54) % H, 255, 255, 255) end rect(0, 0, W, 4, 112, 84, 58) rect(0, H - 4, W, 4, 112, 84, 58) rect(0, 0, 4, H, 112, 84, 58) rect(W - 4, 0, 4, H, 112, 84, 58) rect(30, 0, 4, H, 112, 84, 58) rect(0, 30, W, 4, 112, 84, 58) rect(34, 0, 1, H, 82, 60, 42) rect(0, 34, W, 1, 82, 60, 42) end