Add web/ — PTY+WebSocket server, xterm.js PWA client, Dockerfile, and PyInstaller notes
This commit is contained in:
30
web/static/generate_icons.py
Normal file
30
web/static/generate_icons.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Generate solid-colour placeholder PNG icons for the PWA manifest."""
|
||||
import struct
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _chunk(chunk_type, data):
|
||||
c = chunk_type + data
|
||||
crc = struct.pack(">I", zlib.crc32(c) & 0xFFFFFFFF)
|
||||
return struct.pack(">I", len(data)) + c + crc
|
||||
|
||||
|
||||
def solid_png(width, height, r, g, b):
|
||||
header = b"\x89PNG\r\n\x1a\n"
|
||||
ihdr = _chunk(b"IHDR", struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0))
|
||||
raw = bytearray()
|
||||
for _ in range(height):
|
||||
raw.append(0)
|
||||
raw.extend(bytes([r, g, b]) * width)
|
||||
idat = _chunk(b"IDAT", zlib.compress(bytes(raw)))
|
||||
iend = _chunk(b"IEND", b"")
|
||||
return header + ihdr + idat + iend
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dst = Path(__file__).parent
|
||||
for size in (192, 512):
|
||||
path = dst / f"icon-{size}.png"
|
||||
path.write_bytes(solid_png(size, size, 0x1A, 0x1A, 0x2E))
|
||||
print(f"Created {path.name} ({size}x{size})")
|
||||
Reference in New Issue
Block a user