Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/bskycam.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101#!/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 charcoalEDGE = (12, 12, 14, 255) # near-black outlineGRIP = (60, 60, 68, 255) # lighter top stripLENS_O = (70, 70, 80, 255) # lens outer ringLENS_M = (110, 120, 150, 255) # lens mid glassLENS_I = (180, 220, 255, 255) # lens bright highlightSHUTR = (200, 40, 40, 255) # red shutter buttonSHUTR_E= (120, 20, 20, 255) # shutter edgeFLASH = (255, 245, 200, 255) # flash squareFLASH_E= (150, 140, 90, 255) # flash edgeSKY = (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 outlinerect(px, 1, 4, 14, 4, EDGE) # toprect(px, 1, 13, 14, 13, EDGE) # bottomrect(px, 1, 4, 1, 13, EDGE) # leftrect(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 outlinerect(px, 3, 3, 3, 3, EDGE)rect(px, 12, 3, 12, 3, EDGE)
# shutter button (top right): rows 2..3 col 12..13rect(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..3rect(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 4cx, cy = 8, 9ring(px, cx, cy, 4, 3, LENS_O)circle_filled(px, cx, cy, 3, LENS_M)circle_filled(px, cx, cy, 2, SKY)# highlight dotput(px, cx - 1, cy - 1, LENS_I)put(px, cx - 2, cy - 1, LENS_I)
import osout_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"))