# image/spr fixtures (tools/fixtures.py): sprites written from spritegn.h (Quake IDSP 1: two single frames and a # group of three; Half-Life IDSP 2 with its palette, alpha test and index alpha; DarkPlaces SPR32); expected frame # pixels (rgba CRCs), canvas positions from the frame origins, and group delays from the cumulative intervals. # tests/gen/spr.luau { palette, sprites = { { name, data, version, w, h, origin, frames = { { x, y, w, h, crc, delay } } } } } import struct, zlib def frame_bytes(rng, w, h, bpp): return bytes(rng.randrange(256) for _ in range(w * h * bpp)) def rgba(pix, pal, key=None, mode=None): out = bytearray() for i in pix: if mode == "indexalpha": out += pal[255 * 3:255 * 3 + 3] + bytes([i]) elif key is not None and i == key: out += pal[i * 3:i * 3 + 3] + b"\0" else: out += pal[i * 3:i * 3 + 3] + b"\xff" return zlib.crc32(bytes(out)) def sprite(rng, version, layout, pal, tex=3): # layout: list of ("single", (ox, oy, w, h)) or ("group", [intervals], [(ox, oy, w, h)]) singles = [] body = b"" frames = [] for item in layout: if item[0] == "single": body += struct.pack("