Kotlin, Compose for TV and Media3 port of the desktop Musyx, with device-code sign-in, Home, My Wave, search, collection, detail pages, Now Playing with queue and lyrics, and settings for streaming quality, appearance, font size (small, medium, large) and language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
2.8 KiB
Python
Executable File
85 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Draws the Musyx app icon (1024x1024 PNG) with no dependencies.
|
|
|
|
Aubergine squircle with amber wave lines, matching the My Wave hero.
|
|
Usage: python3 tool/make_icon.py assets/icon/musyx.png
|
|
"""
|
|
import math
|
|
import struct
|
|
import sys
|
|
import zlib
|
|
|
|
SIZE = 1024
|
|
# macOS icon grid: the body is 824px, centred, with a ~185px corner radius.
|
|
BODY, RADIUS = 824, 185
|
|
OFF = (SIZE - BODY) / 2
|
|
TOP, BOTTOM = (0x35, 0x30, 0x42), (0x1C, 0x1A, 0x22)
|
|
AMBER = (0xF0, 0xB2, 0x3E)
|
|
LINES = 11
|
|
|
|
|
|
def rounded_alpha(x, y):
|
|
"""Coverage of the rounded square at pixel centre (x, y), anti-aliased."""
|
|
px, py = x + 0.5 - OFF, y + 0.5 - OFF
|
|
cx = min(max(px, RADIUS), BODY - RADIUS)
|
|
cy = min(max(py, RADIUS), BODY - RADIUS)
|
|
d = math.hypot(px - cx, py - cy) - RADIUS
|
|
if px < 0 or py < 0 or px > BODY or py > BODY:
|
|
d = max(d, 1.0)
|
|
return min(max(0.5 - d, 0.0), 1.0)
|
|
|
|
|
|
def wave(k, x):
|
|
"""Height of line k at x, and its slope, in pixels."""
|
|
u = (x - OFF) / BODY
|
|
base = OFF + BODY * (0.34 + k * 0.034)
|
|
amp = BODY * (0.045 + k * 0.006)
|
|
f = 1.5 + k * 0.08
|
|
ph = k * 0.55 + 1.1
|
|
a = u * math.pi * f + ph
|
|
b = u * math.pi * 4.2 - ph * 0.7
|
|
y = base + math.sin(a) * amp + math.sin(b) * amp * 0.35
|
|
dy = (math.cos(a) * amp * math.pi * f + math.cos(b) * amp * 0.35 * math.pi * 4.2) / BODY
|
|
return y, dy
|
|
|
|
|
|
def main(out):
|
|
rows = []
|
|
curves = [[wave(k, x + 0.5) for x in range(SIZE)] for k in range(LINES)]
|
|
for y in range(SIZE):
|
|
row = bytearray([0]) # filter: none
|
|
t = y / SIZE
|
|
bg = tuple(round(TOP[i] + (BOTTOM[i] - TOP[i]) * t) for i in range(3))
|
|
for x in range(SIZE):
|
|
cover = rounded_alpha(x, y)
|
|
if cover == 0.0:
|
|
row += b"\x00\x00\x00\x00"
|
|
continue
|
|
r, g, b = bg
|
|
for k in range(LINES):
|
|
cy, slope = curves[k][x]
|
|
dist = abs(y + 0.5 - cy) / math.sqrt(1 + slope * slope)
|
|
width = 4.0 + k * 0.9
|
|
a = min(max(width / 2 - dist + 0.5, 0.0), 1.0)
|
|
if a:
|
|
a *= 0.18 + 0.82 * (k / (LINES - 1))
|
|
r = r + (AMBER[0] - r) * a
|
|
g = g + (AMBER[1] - g) * a
|
|
b = b + (AMBER[2] - b) * a
|
|
row += bytes((round(r), round(g), round(b), round(cover * 255)))
|
|
rows.append(bytes(row))
|
|
|
|
def chunk(kind, data):
|
|
return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data) & 0xFFFFFFFF)
|
|
|
|
png = b"\x89PNG\r\n\x1a\n"
|
|
png += chunk(b"IHDR", struct.pack(">IIBBBBB", SIZE, SIZE, 8, 6, 0, 0, 0))
|
|
png += chunk(b"IDAT", zlib.compress(b"".join(rows), 9))
|
|
png += chunk(b"IEND", b"")
|
|
with open(out, "wb") as f:
|
|
f.write(png)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv[1] if len(sys.argv) > 1 else "musyx.png")
|