mirror of
https://github.com/blazblue547-afk/aero3.git
synced 2026-12-02 14:24:17 -05:00
Initial AeroOS source
This commit is contained in:
commit
b27732ad89
42 files changed
+3775
No files matched your search
@@ -0,0 +1,37 @@
|
||||
set default=0
|
||||
set timeout=8
|
||||
|
||||
insmod iso9660
|
||||
insmod search
|
||||
insmod search_label
|
||||
insmod linux
|
||||
terminal_output console
|
||||
set gfxpayload=text
|
||||
|
||||
menuentry "AeroOS @@VERSION@@ (Live)" {
|
||||
search --no-floppy --set=root --label @@ISO_LABEL@@
|
||||
echo "Loading AeroOS kernel..."
|
||||
linux /boot/vmlinuz-aeros root=live:LABEL=@@ISO_LABEL@@ rd.live.image console=tty0 loglevel=7
|
||||
echo "Loading AeroOS initramfs..."
|
||||
initrd /boot/initrd-aeros.img
|
||||
echo "Booting AeroOS..."
|
||||
boot
|
||||
}
|
||||
menuentry "AeroOS @@VERSION@@ (Live, safe graphics / software render)" {
|
||||
search --no-floppy --set=root --label @@ISO_LABEL@@
|
||||
echo "Loading AeroOS kernel..."
|
||||
linux /boot/vmlinuz-aeros root=live:LABEL=@@ISO_LABEL@@ rd.live.image nomodeset console=tty0 loglevel=7
|
||||
echo "Loading AeroOS initramfs..."
|
||||
initrd /boot/initrd-aeros.img
|
||||
echo "Booting AeroOS..."
|
||||
boot
|
||||
}
|
||||
menuentry "AeroOS @@VERSION@@ (verbose / debug)" {
|
||||
search --no-floppy --set=root --label @@ISO_LABEL@@
|
||||
echo "Loading AeroOS kernel..."
|
||||
linux /boot/vmlinuz-aeros root=live:LABEL=@@ISO_LABEL@@ rd.live.image debug console=tty0 console=ttyS0,115200n8 loglevel=7 ignore_loglevel initcall_debug
|
||||
echo "Loading AeroOS initramfs..."
|
||||
initrd /boot/initrd-aeros.img
|
||||
echo "Booting AeroOS..."
|
||||
boot
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
# AeroOS live initramfs init.
|
||||
# Built-in kernel support is assumed for: iso9660, squashfs, overlay, loop.
|
||||
# Finds the live medium, mounts the squashfs read-only, layers a tmpfs via
|
||||
# overlayfs, then switches root into the real AeroOS system (systemd).
|
||||
/bin/busybox --install -s /bin 2>/dev/null
|
||||
[ -c /dev/console ] && exec </dev/console >/dev/console 2>&1
|
||||
|
||||
mount -t proc proc /proc
|
||||
mount -t sysfs sysfs /sys
|
||||
mount -t devtmpfs devtmpfs /dev 2>/dev/null
|
||||
|
||||
LABEL="@@ISO_LABEL@@"
|
||||
SQUASH="/run/iso/LiveOS/aeros.squashfs"
|
||||
|
||||
echo "AeroOS: locating live medium (label $LABEL)..."
|
||||
mkdir -p /run/iso /run/sqfs /run/overlay /sysroot
|
||||
|
||||
# wait for the CD/USB to appear, then mount by label
|
||||
dev=""
|
||||
for try in $(seq 1 30); do
|
||||
for d in /dev/sr0 /dev/sr1 $(ls /dev/sd? /dev/sd?? /dev/vd? 2>/dev/null); do
|
||||
[ -b "$d" ] || continue
|
||||
if blkid "$d" 2>/dev/null | grep -q "LABEL=\"$LABEL\""; then dev="$d"; break; fi
|
||||
done
|
||||
[ -n "$dev" ] && break
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
[ -n "$dev" ] || { echo "AeroOS: live medium not found"; exec sh; }
|
||||
echo "AeroOS: live medium = $dev"
|
||||
mount -t iso9660 -o ro "$dev" /run/iso || { echo "iso mount failed"; exec sh; }
|
||||
|
||||
# mount the squashfs (read-only lower layer)
|
||||
mount -t squashfs -o ro,loop "$SQUASH" /run/sqfs || { echo "squashfs mount failed"; exec sh; }
|
||||
|
||||
# writable overlay in RAM
|
||||
mount -t tmpfs tmpfs /run/overlay
|
||||
mkdir -p /run/overlay/upper /run/overlay/work
|
||||
mount -t overlay overlay \
|
||||
-o lowerdir=/run/sqfs,upperdir=/run/overlay/upper,workdir=/run/overlay/work \
|
||||
/sysroot || { echo "overlay mount failed"; exec sh; }
|
||||
|
||||
# move the already-mounted vkfs into the new root and switch
|
||||
mkdir -p /sysroot/run/iso
|
||||
mount --move /run/iso /sysroot/run/iso 2>/dev/null
|
||||
for fs in proc sys dev; do mount --move /$fs /sysroot/$fs 2>/dev/null; done
|
||||
|
||||
echo "AeroOS: switching root -> systemd"
|
||||
exec switch_root /sysroot /sbin/init
|
||||
Executable
+142
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate a subtle, seamless lofi loop for the AeroOS home screen.
|
||||
|
||||
Pure standard library (math/struct/wave) so it runs on any host with python3.
|
||||
Synthesizes a mellow jazzy chord progression with soft keys, a quiet kick,
|
||||
brushed hats and gentle vinyl crackle, then writes a 16-bit stereo WAV that
|
||||
loops seamlessly (whole number of bars).
|
||||
|
||||
Usage: generate_lofi.py OUTPUT.wav
|
||||
"""
|
||||
import math
|
||||
import random
|
||||
import struct
|
||||
import sys
|
||||
import wave
|
||||
|
||||
SR = 44100
|
||||
BPM = 72
|
||||
BEAT = 60.0 / BPM
|
||||
BAR = BEAT * 4
|
||||
BARS = 8 # loop length in bars -> seamless
|
||||
DUR = BAR * BARS
|
||||
|
||||
# Jazzy ii-V-I-vi style progression (root freqs, Hz) per 2 bars.
|
||||
# Each chord is a list of semitone offsets from the root.
|
||||
A = 220.0
|
||||
def note(semis, base=A):
|
||||
return base * (2 ** (semis / 12.0))
|
||||
|
||||
CHORDS = [ # (root_semitone_from_A, [chord tones as semitone offsets])
|
||||
(3, [0, 4, 7, 11]), # Cmaj7
|
||||
(0, [0, 3, 7, 10]), # Am7
|
||||
(5, [0, 3, 7, 10]), # Dm7
|
||||
(10, [0, 4, 7, 10]), # G7
|
||||
]
|
||||
|
||||
def soft_clip(x):
|
||||
return math.tanh(x * 1.2)
|
||||
|
||||
def main(out_path):
|
||||
random.seed(7)
|
||||
n = int(DUR * SR)
|
||||
left = [0.0] * n
|
||||
right = [0.0] * n
|
||||
|
||||
chord_len = DUR / len(CHORDS)
|
||||
|
||||
# --- pad / electric-piano-ish chords (detuned sines + slow tremolo) ---
|
||||
for ci, (root, tones) in enumerate(CHORDS):
|
||||
start = int(ci * chord_len * SR)
|
||||
end = int((ci + 1) * chord_len * SR)
|
||||
for t in tones:
|
||||
f = note(root + t, base=A) / 2.0 # one octave down, warm
|
||||
detune = 1.003
|
||||
for i in range(start, end):
|
||||
tt = (i - start) / SR
|
||||
env = min(tt / 0.04, 1.0) * math.exp(-tt * 0.25) # soft pluck
|
||||
trem = 0.92 + 0.08 * math.sin(2 * math.pi * 4.7 * tt)
|
||||
s = (math.sin(2 * math.pi * f * tt)
|
||||
+ 0.5 * math.sin(2 * math.pi * f * detune * tt)
|
||||
+ 0.25 * math.sin(2 * math.pi * f * 2 * tt))
|
||||
s *= 0.085 * env * trem
|
||||
# gentle stereo spread by tone index
|
||||
pan = 0.5 + 0.12 * math.sin(t)
|
||||
left[i] += s * (1 - pan + 0.5)
|
||||
right[i] += s * (pan + 0.5)
|
||||
|
||||
# --- bass (root, one more octave down) ---
|
||||
for ci, (root, _tones) in enumerate(CHORDS):
|
||||
start = int(ci * chord_len * SR)
|
||||
end = int((ci + 1) * chord_len * SR)
|
||||
f = note(root, base=A) / 4.0
|
||||
for i in range(start, end):
|
||||
tt = (i - start) / SR
|
||||
env = min(tt / 0.02, 1.0) * math.exp(-tt * 0.6)
|
||||
s = 0.16 * env * soft_clip(math.sin(2 * math.pi * f * tt))
|
||||
left[i] += s
|
||||
right[i] += s
|
||||
|
||||
# --- drums: soft kick on 1 & 3, brushed hat on offbeats ---
|
||||
total_beats = int(DUR / BEAT)
|
||||
for b in range(total_beats):
|
||||
bt = b * BEAT
|
||||
# kick
|
||||
if b % 2 == 0:
|
||||
ks = int(bt * SR)
|
||||
for i in range(ks, min(ks + int(0.18 * SR), n)):
|
||||
tt = (i - ks) / SR
|
||||
fk = 110 * math.exp(-tt * 24) + 45
|
||||
s = 0.5 * math.exp(-tt * 12) * math.sin(2 * math.pi * fk * tt)
|
||||
left[i] += s; right[i] += s
|
||||
# hat (off-beat)
|
||||
hs = int((bt + BEAT / 2) * SR)
|
||||
for i in range(hs, min(hs + int(0.05 * SR), n)):
|
||||
tt = (i - hs) / SR
|
||||
s = 0.06 * math.exp(-tt * 60) * (random.random() * 2 - 1)
|
||||
left[i] += s; right[i] += s
|
||||
|
||||
# --- vinyl crackle + tape hiss (very subtle) ---
|
||||
for i in range(n):
|
||||
hiss = (random.random() * 2 - 1) * 0.006
|
||||
crackle = 0.0
|
||||
if random.random() < 0.0009:
|
||||
crackle = (random.random() * 2 - 1) * 0.18
|
||||
left[i] += hiss + crackle
|
||||
right[i] += hiss + crackle
|
||||
|
||||
# --- simple one-pole low-pass for that warm muffled lofi tone ---
|
||||
def lowpass(buf, a=0.18):
|
||||
prev = 0.0
|
||||
for i in range(len(buf)):
|
||||
prev = prev + a * (buf[i] - prev)
|
||||
buf[i] = prev
|
||||
lowpass(left); lowpass(right)
|
||||
|
||||
# --- crossfade head/tail so the loop is seamless ---
|
||||
xf = int(0.25 * SR)
|
||||
for i in range(xf):
|
||||
g = i / xf
|
||||
left[i] = left[i] * g + left[n - xf + i] * (1 - g)
|
||||
right[i] = right[i] * g + right[n - xf + i] * (1 - g)
|
||||
|
||||
# --- master gain + soft clip, write 16-bit stereo ---
|
||||
peak = max(1e-6, max(max(abs(x) for x in left), max(abs(x) for x in right)))
|
||||
gain = 0.5 / peak # keep it subtle (headroom)
|
||||
with wave.open(out_path, "wb") as w:
|
||||
w.setnchannels(2)
|
||||
w.setsampwidth(2)
|
||||
w.setframerate(SR)
|
||||
frames = bytearray()
|
||||
for i in range(n):
|
||||
l = int(soft_clip(left[i] * gain) * 30000)
|
||||
r = int(soft_clip(right[i] * gain) * 30000)
|
||||
frames += struct.pack("<hh", max(-32768, min(32767, l)),
|
||||
max(-32768, min(32767, r)))
|
||||
w.writeframes(bytes(frames))
|
||||
print(f"wrote {out_path}: {DUR:.1f}s, {n} frames")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit("usage: generate_lofi.py OUTPUT.wav")
|
||||
main(sys.argv[1])
|
||||
@@ -0,0 +1,114 @@
|
||||
/* AeroGlass — a glassmorphism GTK4 theme for AeroOS.
|
||||
* Translucent frosted surfaces, soft white borders, rounded corners and the
|
||||
* cool cyan Frutiger Aero accent. Pairs with the aerowm compositor, whose
|
||||
* blurred wallpaper backdrop shows through these translucent windows. */
|
||||
|
||||
@define-color aero_accent #29a8e0;
|
||||
@define-color aero_accent_rgb rgb(41,168,224);
|
||||
@define-color aero_glass rgba(255,255,255,0.16);
|
||||
@define-color aero_glass_hi rgba(255,255,255,0.30);
|
||||
@define-color aero_text #0b2a3f;
|
||||
@define-color aero_text_light #eaf7ff;
|
||||
|
||||
* {
|
||||
outline-color: rgba(41,168,224,0.55);
|
||||
}
|
||||
|
||||
window, .background {
|
||||
background-color: rgba(225,245,255,0.10);
|
||||
color: @aero_text_light;
|
||||
}
|
||||
|
||||
/* Frosted top bars / headerbars */
|
||||
headerbar, .titlebar {
|
||||
background: linear-gradient(to bottom,
|
||||
rgba(255,255,255,0.34),
|
||||
rgba(255,255,255,0.14));
|
||||
border-bottom: 1px solid rgba(255,255,255,0.45);
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
|
||||
color: @aero_text_light;
|
||||
border-radius: 14px 14px 0 0;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
/* Generic frosted glass containers */
|
||||
.card, popover > contents, .osd, infobar, .glass {
|
||||
background: rgba(255,255,255,0.16);
|
||||
border: 1px solid rgba(255,255,255,0.40);
|
||||
border-radius: 18px;
|
||||
box-shadow: 0 8px 30px rgba(8,36,63,0.28),
|
||||
inset 0 1px 0 rgba(255,255,255,0.55);
|
||||
color: @aero_text_light;
|
||||
}
|
||||
|
||||
/* Buttons: glossy aqua pills */
|
||||
button {
|
||||
background: linear-gradient(to bottom,
|
||||
rgba(255,255,255,0.40),
|
||||
rgba(255,255,255,0.12));
|
||||
border: 1px solid rgba(255,255,255,0.50);
|
||||
border-radius: 12px;
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
|
||||
color: @aero_text_light;
|
||||
padding: 6px 14px;
|
||||
transition: all 150ms ease;
|
||||
}
|
||||
button:hover {
|
||||
background: linear-gradient(to bottom,
|
||||
rgba(173,224,255,0.55),
|
||||
rgba(41,168,224,0.30));
|
||||
}
|
||||
button:active {
|
||||
background: rgba(41,168,224,0.45);
|
||||
box-shadow: inset 0 2px 6px rgba(8,36,63,0.35);
|
||||
}
|
||||
button.suggested-action {
|
||||
background: linear-gradient(to bottom,
|
||||
rgba(94,200,255,0.85),
|
||||
rgba(41,168,224,0.85));
|
||||
border-color: rgba(255,255,255,0.7);
|
||||
}
|
||||
|
||||
/* Entries */
|
||||
entry, spinbutton, textview text {
|
||||
background: rgba(255,255,255,0.22);
|
||||
border: 1px solid rgba(255,255,255,0.45);
|
||||
border-radius: 10px;
|
||||
color: @aero_text_light;
|
||||
caret-color: @aero_accent_rgb;
|
||||
}
|
||||
entry:focus-within {
|
||||
border-color: @aero_accent_rgb;
|
||||
box-shadow: 0 0 0 2px rgba(41,168,224,0.45);
|
||||
}
|
||||
|
||||
/* Selections, switches, progress */
|
||||
selection { background-color: rgba(41,168,224,0.55); }
|
||||
switch:checked { background: @aero_accent_rgb; }
|
||||
progressbar progress, scale highlight {
|
||||
background: linear-gradient(to right, #7fdcff, #29a8e0);
|
||||
}
|
||||
|
||||
/* Scrollbars: slim translucent */
|
||||
scrollbar slider {
|
||||
background: rgba(255,255,255,0.45);
|
||||
border-radius: 10px;
|
||||
min-width: 8px; min-height: 8px;
|
||||
}
|
||||
|
||||
/* Menus / popovers */
|
||||
menu, .menu, popover {
|
||||
background: rgba(20,60,90,0.35);
|
||||
border-radius: 16px;
|
||||
}
|
||||
menuitem:hover, row:selected {
|
||||
background: rgba(41,168,224,0.40);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
tooltip {
|
||||
background: rgba(11,42,63,0.75);
|
||||
border: 1px solid rgba(255,255,255,0.35);
|
||||
border-radius: 10px;
|
||||
color: @aero_text_light;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
[Settings]
|
||||
gtk-application-prefer-dark-theme=true
|
||||
gtk-theme-name=AeroGlass
|
||||
gtk-font-name=DejaVu Sans 11
|
||||
gtk-cursor-theme-size=24
|
||||
gtk-enable-animations=true
|
||||
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AeroOS default wallpaper — "Frutiger Aero" aesthetic:
|
||||
glossy sky gradient, soft clouds, sun bloom + lens flare, translucent
|
||||
bubbles/orbs, a glossy green hill and a reflective water band. 1920x1080. -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1920" height="1080"
|
||||
viewBox="0 0 1920 1080">
|
||||
<defs>
|
||||
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#0a3d8f"/>
|
||||
<stop offset="35%" stop-color="#1f7ed6"/>
|
||||
<stop offset="70%" stop-color="#69c6f5"/>
|
||||
<stop offset="100%" stop-color="#bfeeff"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="sun" cx="74%" cy="20%" r="40%">
|
||||
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.95"/>
|
||||
<stop offset="18%" stop-color="#fff6cf" stop-opacity="0.8"/>
|
||||
<stop offset="45%" stop-color="#bfe9ff" stop-opacity="0.25"/>
|
||||
<stop offset="100%" stop-color="#bfe9ff" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<linearGradient id="hill" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#9fe04a"/>
|
||||
<stop offset="40%" stop-color="#5fb828"/>
|
||||
<stop offset="100%" stop-color="#2f7d12"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="hillgloss" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.55"/>
|
||||
<stop offset="100%" stop-color="#ffffff" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="water" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#bfeeff" stop-opacity="0.9"/>
|
||||
<stop offset="100%" stop-color="#2f9fd6" stop-opacity="0.9"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="orb" cx="35%" cy="30%" r="75%">
|
||||
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.95"/>
|
||||
<stop offset="35%" stop-color="#cfeffe" stop-opacity="0.45"/>
|
||||
<stop offset="80%" stop-color="#8fd6f7" stop-opacity="0.18"/>
|
||||
<stop offset="100%" stop-color="#8fd6f7" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<filter id="soft" x="-30%" y="-30%" width="160%" height="160%">
|
||||
<feGaussianBlur stdDeviation="14"/>
|
||||
</filter>
|
||||
<filter id="softer" x="-50%" y="-50%" width="200%" height="200%">
|
||||
<feGaussianBlur stdDeviation="30"/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<!-- sky + sun bloom -->
|
||||
<rect width="1920" height="1080" fill="url(#sky)"/>
|
||||
<rect width="1920" height="1080" fill="url(#sun)"/>
|
||||
|
||||
<!-- soft clouds -->
|
||||
<g fill="#ffffff" opacity="0.85" filter="url(#soft)">
|
||||
<ellipse cx="320" cy="180" rx="220" ry="70"/>
|
||||
<ellipse cx="520" cy="210" rx="180" ry="60"/>
|
||||
<ellipse cx="1500" cy="120" rx="260" ry="80"/>
|
||||
<ellipse cx="1180" cy="300" rx="160" ry="48"/>
|
||||
</g>
|
||||
|
||||
<!-- lens-flare specks -->
|
||||
<g fill="#ffffff">
|
||||
<circle cx="1421" cy="216" r="9" opacity="0.9"/>
|
||||
<circle cx="1180" cy="360" r="20" opacity="0.25"/>
|
||||
<circle cx="980" cy="470" r="13" opacity="0.30"/>
|
||||
<circle cx="760" cy="560" r="28" opacity="0.18"/>
|
||||
</g>
|
||||
|
||||
<!-- glossy green hill -->
|
||||
<path d="M0,760 C 420,650 900,720 1280,690 C 1600,665 1800,700 1920,680 L1920,1080 L0,1080 Z"
|
||||
fill="url(#hill)"/>
|
||||
<path d="M0,760 C 420,650 900,720 1280,690 C 1600,665 1800,700 1920,680 L1920,792
|
||||
C 1740,772 1500,800 1180,792 C 820,782 360,742 0,824 Z"
|
||||
fill="url(#hillgloss)" opacity="0.5"/>
|
||||
|
||||
<!-- reflective water band -->
|
||||
<path d="M0,930 C 500,905 1200,945 1920,915 L1920,1080 L0,1080 Z"
|
||||
fill="url(#water)"/>
|
||||
<g stroke="#ffffff" stroke-opacity="0.5" stroke-width="3" fill="none">
|
||||
<path d="M120,985 q 140,-14 280,0"/>
|
||||
<path d="M620,1010 q 160,-14 320,0"/>
|
||||
<path d="M1180,980 q 150,-12 300,0"/>
|
||||
</g>
|
||||
|
||||
<!-- floating translucent bubbles/orbs -->
|
||||
<g>
|
||||
<circle cx="300" cy="520" r="120" fill="url(#orb)"/>
|
||||
<circle cx="1580" cy="430" r="170" fill="url(#orb)"/>
|
||||
<circle cx="980" cy="250" r="70" fill="url(#orb)"/>
|
||||
<circle cx="1300" cy="600" r="60" fill="url(#orb)"/>
|
||||
<circle cx="640" cy="360" r="45" fill="url(#orb)"/>
|
||||
<circle cx="1750" cy="780" r="90" fill="url(#orb)" opacity="0.8"/>
|
||||
<circle cx="170" cy="820" r="55" fill="url(#orb)" opacity="0.8"/>
|
||||
</g>
|
||||
|
||||
<!-- bottom vignette for depth -->
|
||||
<rect y="900" width="1920" height="180" fill="#06243f" opacity="0.18" filter="url(#softer)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.2 KiB |
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#!/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()
|
||||
Reference in new issue
Block a user