| 945 | |
| 946 | |
| 947 | def render_hex_map(cfg: Config, tiles: dict[str, list[Image.Image]], tilemap: np.ndarray, dy: np.ndarray, out_path: str) -> None: |
| 948 | max_up = cfg.height_px + 28 |
| 949 | out_w = cfg.row_off_x + (cfg.cols - 1) * cfg.step_x + cfg.tile_w |
| 950 | out_h = (cfg.rows - 1) * cfg.row_step_y + cfg.tile_h + max_up |
| 951 | out_img = Image.new("RGBA", (out_w, out_h), (0, 0, 0, 0)) |
| 952 | |
| 953 | for r in range(cfg.rows): |
| 954 | base_x = cfg.row_off_x if (r % 2 == 1) else 0 |
| 955 | base_y = r * cfg.row_step_y + max_up |
| 956 | for c in range(cfg.cols): |
| 957 | out_img.alpha_composite( |
| 958 | pick_variant(tiles, str(tilemap[r, c]), cfg.seed, r, c), |
| 959 | (base_x + c * cfg.step_x, base_y + int(dy[r, c])), |
| 960 | ) |
| 961 | |
| 962 | out_img.save(out_path) |
| 963 | print(f"Saved {out_path} seed={cfg.seed}") |
| 964 | |
| 965 | |
| 966 | def _connected_components_hex(mask: np.ndarray) -> list[list[tuple[int, int]]]: |