Synthwave wallpapers, drawn with code

Wanted a synthwave wallpaper with green grid lines. The one I found was a watermarked stock preview, so I had Claude draw one from scratch instead. It's a Python script that writes an SVG, and headless Edge turns that into a 4K PNG.

Also made a magenta one and an outrun one with a cyan grid and a yellow-to-pink sun.


I'm also using it as my Windows Terminal background with the retro terminal effects turned on. That's under Settings > your profile > Appearance > Retro terminal effects, and you set the image as the background image on the same page. The effect adds scan lines and a glow to the text.

https://learn.microsoft.com/en-us/windows/terminal/customize-settings/profile-appearance
Put both files in the same folder. Run .\render.ps1 for all three colors, or .\render.ps1 magenta for one. You need Python and Edge, nothing else. Add your own colors to PALETTES at the top of the script.
synthwave.py:
import random
import sys
W, H = 3840, 2160
HORIZON = 1240
CX = W / 2
PALETTES = {
"green": {
"line": "#39ff6a", "star": "#d8ffe2",
"sky_mid": "#010a03", "sky_low": "#06301a",
"floor_top": "#06301a", "floor_mid": "#021208",
"sun_top": "#b6ffc8", "sun_bottom": "#1fd650",
"horizon": "#f2fff5",
},
"magenta": {
"line": "#ff2bd6", "star": "#ffd6f5",
"sky_mid": "#0a0110", "sky_low": "#33063a",
"floor_top": "#33063a", "floor_mid": "#12021a",
"sun_top": "#ffc8f2", "sun_bottom": "#e016b4",
"horizon": "#fff0fb",
},
"outrun": {
"line": "#22e4ff", "star": "#ffffff",
"sky_mid": "#0d0221", "sky_low": "#4a0b52",
"floor_top": "#2a0838", "floor_mid": "#0b0218",
"sun_top": "#ffe14d", "sun_bottom": "#ff2e88",
"horizon": "#ff8ae2",
},
}
out_path = sys.argv[1]
p = PALETTES[sys.argv[2] if len(sys.argv) > 2 else "green"]
random.seed(7)
out = []
add = out.append
add(f'<svg xmlns="http://www.w3.org/2000/svg" width="{W}" height="{H}" viewBox="0 0 {W} {H}">')
add(f"""<defs>
<filter id="glow" x="-20%" y="-20%" width="140%" height="140%">
<feGaussianBlur stdDeviation="10" result="b1"/>
<feGaussianBlur in="SourceGraphic" stdDeviation="3" result="b2"/>
<feMerge><feMergeNode in="b1"/><feMergeNode in="b2"/><feMergeNode in="SourceGraphic"/></feMerge>
</filter>
<filter id="bigglow" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur stdDeviation="40"/>
</filter>
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#000"/>
<stop offset="0.75" stop-color="{p['sky_mid']}"/>
<stop offset="1" stop-color="{p['sky_low']}"/>
</linearGradient>
<linearGradient id="floor" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="{p['floor_top']}"/>
<stop offset="0.12" stop-color="{p['floor_mid']}"/>
<stop offset="1" stop-color="#000"/>
</linearGradient>
<linearGradient id="sunfill" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="{p['sun_top']}"/>
<stop offset="1" stop-color="{p['sun_bottom']}"/>
</linearGradient>
<linearGradient id="gridfade" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#fff" stop-opacity="0"/>
<stop offset="0.3" stop-color="#fff" stop-opacity="1"/>
</linearGradient>
<mask id="gridmask"><rect x="0" y="{HORIZON}" width="{W}" height="{H - HORIZON}" fill="url(#gridfade)"/></mask>
</defs>""")
add(f'<rect width="{W}" height="{HORIZON}" fill="url(#sky)"/>')
# stars
for _ in range(650):
x, y = random.uniform(0, W), random.uniform(0, HORIZON - 20)
r = random.choice([1.2, 1.6, 2.2, 3.0]) if random.random() < 0.9 else 4.2
op = random.uniform(0.25, 0.9) * (0.5 + 0.5 * (1 - y / HORIZON))
color = p["line"] if random.random() < 0.6 else p["star"]
add(f'<circle cx="{x:.1f}" cy="{y:.1f}" r="{r}" fill="{color}" opacity="{op:.2f}"/>')
# sun: horizontal stripes clipped to a circle, gaps widening toward the horizon
R = 620
sun_cy = HORIZON - 120
add(f'<circle cx="{CX}" cy="{sun_cy}" r="{R}" fill="{p["sun_bottom"]}" opacity="0.18" filter="url(#bigglow)"/>')
add(f'<clipPath id="sunclip"><circle cx="{CX}" cy="{sun_cy}" r="{R}"/></clipPath>')
add(f'<clipPath id="abovehz"><rect width="{W}" height="{HORIZON}"/></clipPath>')
add('<g clip-path="url(#abovehz)"><g clip-path="url(#sunclip)" filter="url(#glow)">')
y = sun_cy - R
band, gap = 46.0, 6.0
while y < HORIZON:
add(f'<rect x="{CX - R}" y="{y:.1f}" width="{2 * R}" height="{band:.1f}" fill="url(#sunfill)"/>')
y += band + gap
band = max(10.0, band * 0.86)
gap = gap * 1.22 + 2
add("</g></g>")
# floor
add(f'<rect y="{HORIZON}" width="{W}" height="{H - HORIZON}" fill="url(#floor)"/>')
add(f'<g mask="url(#gridmask)" stroke="{p["line"]}" fill="none" filter="url(#glow)">')
# depth lines: y = horizon + k / depth
k = (H - HORIZON) * 0.9
d = 0.6
while True:
y = HORIZON + k / d
if y - HORIZON < 22:
break
if y <= H:
width = max(1.5, 7 * (y - HORIZON) / (H - HORIZON))
add(f'<line x1="0" y1="{y:.1f}" x2="{W}" y2="{y:.1f}" stroke-width="{width:.1f}"/>')
d += 0.55
# rays from the vanishing point
spacing = 330
for i in range(-36, 37):
x_bottom = CX + i * spacing
add(f'<line x1="{CX}" y1="{HORIZON}" x2="{x_bottom:.1f}" y2="{H + 40}" stroke-width="5"/>')
add("</g>")
# horizon line
add(f'<rect x="0" y="{HORIZON - 40}" width="{W}" height="80" fill="{p["line"]}" opacity="0.2" filter="url(#bigglow)"/>')
add(f'<line x1="0" y1="{HORIZON}" x2="{W}" y2="{HORIZON}" stroke="{p["horizon"]}" stroke-width="10" filter="url(#glow)"/>')
add("</svg>")
with open(out_path, "w", encoding="utf-8") as f:
f.write("\n".join(out))
render.ps1:
# Renders each palette in synthwave.py to a 4K PNG through headless Edge.
# Usage: .\render.ps1 (all palettes)
# .\render.ps1 magenta (one palette)
param([string[]]$Palette = @("green", "magenta", "outrun"))
$here = $PSScriptRoot
$edge = "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe"
foreach ($name in $Palette) {
$svg = "synthwave-$name.svg"
$html = "$here\synthwave-$name.html"
$png = "$here\synthwave-$name.png"
python "$here\synthwave.py" "$here\$svg" $name
Set-Content $html "<html><body style='margin:0;background:#000'><img src='$svg' style='display:block'></body></html>"
$url = "file:///" + $html.Replace([char]92, [char]47)
& $edge --headless=new --disable-gpu --hide-scrollbars --force-device-scale-factor=1 --window-size=3840,2160 --screenshot="$png" $url 2>&1 | Out-Null
Remove-Item $html
Write-Host "Saved $png"
}
Drafted with an assistant, edited by @wintaru
0 comments