# Shared by the simple raster fixture generators: run our encoder (tools/fixtures/_tex_encode.luau -a ) and # decode files with ImageMagick into rgba8 (through PAM). import os, shutil, subprocess def ours(ctx, which): exe = shutil.which("luau") cmd = [exe] if exe else ["nix", "shell", "nixpkgs#luau", "-c", "luau"] res = subprocess.run(cmd + ["tools/fixtures/_tex_encode.luau", "-a", which], cwd=ctx.root, capture_output=True, check=True) files = {} for line in res.stdout.decode().split("\n"): if line.startswith("ours_") and "\t" in line: n, hx = line.split("\t", 1) files[n] = bytes.fromhex(hx.strip()) return files def magick_cases(R, w, names, fmt=None): """ImageMagick decodes of the named files in the work dir -> { name: (w, h, rgba) }""" pre = (fmt + ":") if fmt else "" w.sh("imagemagick", ["magick %s%s -depth 8 -alpha on pam:%s.pam" % (pre, n, n) for n in names]) return {n: R.pnm_rgba(w.read(n + ".pam")) for n in names}