"""Analyze the color content of level tile PNGs.""" import os os.environ['PATH'] = r"C:\Program Files\GTK3-Runtime Win64\bin" + os.pathsep + os.environ.get('PATH', '') from PIL import Image from collections import Counter def analyze_tile(tile_path): """Analyze the colors in a tile image.""" img = Image.open(tile_path).convert('RGBA') pixels = list(img.getdata()) # Count colors color_counts = Counter() for pixel in pixels: # Ignore fully transparent pixels if pixel[3] > 0: color_counts[pixel[:3]] += 1 return color_counts.most_common(20) def main(): tiles_dir = "assets/level_tiles/png" # Check first few tiles for tile_name in ["Level_1_1.png", "Level_1_2.png", "Level_1_3.png", "Level_1_4.png", "Level_1_5.png"]: tile_path = os.path.join(tiles_dir, tile_name) if os.path.exists(tile_path): print(f"\n=== {tile_name} ===") colors = analyze_tile(tile_path) for color, count in colors: r, g, b = color hex_color = f"#{r:02x}{g:02x}{b:02x}" print(f" {hex_color}: {count} pixels") if __name__ == "__main__": main()