#!/usr/bin/env python3 """Generate a 16x16 camera PNG for the bskycam mod.""" import struct, zlib W = H = 16 def chunk(ctype, data): return struct.pack(">I", len(data)) + ctype + data + struct.pack(">I", zlib.crc32(ctype + data) & 0xffffffff) def make_png(pixels, path): raw = b"" for y in range(H): raw += b"\x00" for x in range(W): r, g, b, a = pixels[y * W + x] raw += struct.pack("BBBB", r, g, b, a) sig = b"\x89PNG\r\n\x1a\n" ihdr = struct.pack(">IIBBBBB", W, H, 8, 6, 0, 0, 0) with open(path, "wb") as f: f.write(sig + chunk(b"IHDR", ihdr) + chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b"")) CLEAR = (0, 0, 0, 0) BODY = (30, 30, 34, 255) # dark charcoal EDGE = (12, 12, 14, 255) # near-black outline GRIP = (60, 60, 68, 255) # lighter top strip LENS_O = (70, 70, 80, 255) # lens outer ring LENS_M = (110, 120, 150, 255) # lens mid glass LENS_I = (180, 220, 255, 255) # lens bright highlight SHUTR = (200, 40, 40, 255) # red shutter button SHUTR_E= (120, 20, 20, 255) # shutter edge FLASH = (255, 245, 200, 255) # flash square FLASH_E= (150, 140, 90, 255) # flash edge SKY = (90, 170, 230, 255) # a subtle "sky" accent on lens def put(px, x, y, c): if 0 <= x < W and 0 <= y < H: px[y * W + x] = c def rect(px, x0, y0, x1, y1, c): for y in range(y0, y1 + 1): for x in range(x0, x1 + 1): put(px, x, y, c) def circle_filled(px, cx, cy, r, c): for y in range(cy - r, cy + r + 1): for x in range(cx - r, cx + r + 1): dx, dy = x - cx + 0.5, y - cy + 0.5 if dx * dx + dy * dy <= r * r: put(px, x, y, c) def ring(px, cx, cy, r_out, r_in, c): for y in range(cy - r_out, cy + r_out + 1): for x in range(cx - r_out, cx + r_out + 1): dx, dy = x - cx + 0.5, y - cy + 0.5 d2 = dx * dx + dy * dy if r_in * r_in < d2 <= r_out * r_out: put(px, x, y, c) px = [CLEAR] * (W * H) # body: rows 4..13, cols 1..14 (10 high, 14 wide) rect(px, 1, 4, 14, 13, BODY) # body outline rect(px, 1, 4, 14, 4, EDGE) # top rect(px, 1, 13, 14, 13, EDGE) # bottom rect(px, 1, 4, 1, 13, EDGE) # left rect(px, 14, 4, 14, 13, EDGE) # right # top grip strip rows 2..3, cols 4..11 (viewfinder/pentaprism hump) rect(px, 4, 2, 11, 3, GRIP) rect(px, 4, 2, 11, 2, EDGE) # top outline rect(px, 3, 3, 3, 3, EDGE) rect(px, 12, 3, 12, 3, EDGE) # shutter button (top right): rows 2..3 col 12..13 rect(px, 12, 2, 13, 3, SHUTR) put(px, 12, 2, SHUTR_E) put(px, 13, 2, SHUTR_E) put(px, 13, 3, SHUTR_E) # flash square (top left): rows 2..3 col 2..3 rect(px, 2, 2, 3, 3, FLASH) put(px, 2, 2, FLASH_E) put(px, 3, 2, FLASH_E) put(px, 2, 3, FLASH_E) # lens: centered around (7.5, 8.5), radius 4 cx, cy = 8, 9 ring(px, cx, cy, 4, 3, LENS_O) circle_filled(px, cx, cy, 3, LENS_M) circle_filled(px, cx, cy, 2, SKY) # highlight dot put(px, cx - 1, cy - 1, LENS_I) put(px, cx - 2, cy - 1, LENS_I) import os out_dir = os.path.join(os.path.dirname(__file__), "src", "main", "resources", "assets", "bskycam", "textures", "item") os.makedirs(out_dir, exist_ok=True) make_png(px, os.path.join(out_dir, "camera.png")) print("wrote", os.path.join(out_dir, "camera.png"))