#!/usr/bin/env python3 """Procedural Frutiger Aero wallpaper -> PNG, using only the Python stdlib. Guaranteed to work on any host (no ImageMagick/librsvg/Pillow needed): it draws the scene pixel-by-pixel and encodes a PNG with zlib. The build prefers rsvg-convert on the bundled SVG when available and only falls back to this. Usage: gen_wallpaper.py OUTPUT.png [WIDTH HEIGHT] """ import math import struct import sys import zlib def lerp(a, b, t): return a + (b - a) * t def clamp(v, lo=0.0, hi=255.0): return max(lo, min(hi, v)) def gen(width, height): # precompute a few orbs (x, y, radius) orbs = [ (0.16 * width, 0.48 * height, 0.11 * height), (0.82 * width, 0.40 * height, 0.16 * height), (0.51 * width, 0.23 * height, 0.06 * height), (0.68 * width, 0.56 * height, 0.055 * height), (0.33 * width, 0.33 * height, 0.04 * height), (0.91 * width, 0.72 * height, 0.085 * height), (0.09 * width, 0.76 * height, 0.05 * height), ] sun_x, sun_y = 0.74 * width, 0.20 * height hill_y = 0.70 * height water_y = 0.86 * height raw = bytearray() for y in range(height): raw.append(0) # PNG filter byte: none fy = y / height for x in range(width): fx = x / width # --- sky vertical gradient (deep blue -> pale cyan) --- if fy < 0.35: t = fy / 0.35 r = lerp(10, 31, t); g = lerp(61, 126, t); b = lerp(143, 214, t) elif fy < 0.70: t = (fy - 0.35) / 0.35 r = lerp(31, 105, t); g = lerp(126, 198, t); b = lerp(214, 245, t) else: r, g, b = 191, 238, 255 # --- sun bloom (radial) --- d = math.hypot(x - sun_x, y - sun_y) / (0.42 * width) if d < 1.0: glow = (1.0 - d) ** 2 r = lerp(r, 255, glow * 0.9) g = lerp(g, 250, glow * 0.9) b = lerp(b, 215, glow * 0.7) # --- glossy green hill --- hy = hill_y + 40 * math.sin(fx * math.pi * 1.3) if y > hy: t = clamp((y - hy) / (height - hy)) / 255.0 * 255 tt = (y - hy) / max(1, (height - hy)) hr = lerp(159, 47, tt); hg = lerp(224, 125, tt); hb = lerp(74, 18, tt) # top gloss highlight gloss = max(0.0, 1.0 - (y - hy) / (0.06 * height)) hr = lerp(hr, 255, gloss * 0.5) hg = lerp(hg, 255, gloss * 0.5) hb = lerp(hb, 255, gloss * 0.5) r, g, b = hr, hg, hb # --- reflective water band over the lower area --- if y > water_y: tt = (y - water_y) / max(1, (height - water_y)) wr = lerp(191, 47, tt); wg = lerp(238, 159, tt); wb = lerp(255, 214, tt) r = lerp(r, wr, 0.85); g = lerp(g, wg, 0.85); b = lerp(b, wb, 0.85) if abs(math.sin((fx * 40) + (y * 0.3))) > 0.97: r = lerp(r, 255, 0.4); g = lerp(g, 255, 0.4); b = lerp(b, 255, 0.4) # --- translucent orbs/bubbles --- for ox, oy, orad in orbs: od = math.hypot(x - ox, y - oy) / orad if od < 1.0: # bright rim + soft white core, additive-ish core = (1.0 - od) ** 1.5 rim = math.exp(-((od - 0.85) ** 2) / 0.01) * 0.6 a = clamp((core * 0.45 + rim) , 0, 1) r = lerp(r, 255, a * 0.8) g = lerp(g, 255, a * 0.85) b = lerp(b, 255, a * 0.9) raw.append(int(clamp(r))) raw.append(int(clamp(g))) raw.append(int(clamp(b))) return bytes(raw) def write_png(path, width, height, raw): def chunk(tag, data): c = tag + data return struct.pack(">I", len(data)) + c + struct.pack(">I", zlib.crc32(c) & 0xffffffff) sig = b"\x89PNG\r\n\x1a\n" ihdr = struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0) # 8-bit RGB idat = zlib.compress(raw, 9) with open(path, "wb") as f: f.write(sig) f.write(chunk(b"IHDR", ihdr)) f.write(chunk(b"IDAT", idat)) f.write(chunk(b"IEND", b"")) def main(): if len(sys.argv) < 2: sys.exit("usage: gen_wallpaper.py OUTPUT.png [WIDTH HEIGHT]") out = sys.argv[1] w = int(sys.argv[2]) if len(sys.argv) > 2 else 1920 h = int(sys.argv[3]) if len(sys.argv) > 3 else 1080 write_png(out, w, h, gen(w, h)) print(f"wrote {out} ({w}x{h})") if __name__ == "__main__": main()