Tune large battle map render resolution
This commit is contained in:
@@ -15,7 +15,9 @@ SCENARIO_FILE = ROOT / "src" / "game" / "data" / "scenario.ts"
|
||||
BATTLE_IMAGE_DIR = ROOT / "src" / "assets" / "images" / "battle"
|
||||
DOCS_DIR = ROOT / "docs"
|
||||
|
||||
TILE = 224
|
||||
DEFAULT_TILE_SIZE = 224
|
||||
LARGE_MAP_TILE_SIZE = 192
|
||||
TILE = DEFAULT_TILE_SIZE
|
||||
RNG = random.Random(240704)
|
||||
|
||||
MAP_CONFIGS = {
|
||||
@@ -252,6 +254,7 @@ MAP_CONFIGS = {
|
||||
"out": BATTLE_IMAGE_DIR / "twenty-sixth-battle-map.webp",
|
||||
"before": BATTLE_IMAGE_DIR / "twenty-sixth-battle-map.svg",
|
||||
"seed": 240954,
|
||||
"tile_size": LARGE_MAP_TILE_SIZE,
|
||||
},
|
||||
"twenty-seventh": {
|
||||
"slug": "twenty-seventh-battle-map",
|
||||
@@ -261,6 +264,7 @@ MAP_CONFIGS = {
|
||||
"out": BATTLE_IMAGE_DIR / "twenty-seventh-battle-map.webp",
|
||||
"before": BATTLE_IMAGE_DIR / "twenty-seventh-battle-map.svg",
|
||||
"seed": 240964,
|
||||
"tile_size": LARGE_MAP_TILE_SIZE,
|
||||
},
|
||||
"twenty-eighth": {
|
||||
"slug": "twenty-eighth-battle-map",
|
||||
@@ -270,6 +274,7 @@ MAP_CONFIGS = {
|
||||
"out": BATTLE_IMAGE_DIR / "twenty-eighth-battle-map.webp",
|
||||
"before": BATTLE_IMAGE_DIR / "twenty-eighth-battle-map.svg",
|
||||
"seed": 240974,
|
||||
"tile_size": LARGE_MAP_TILE_SIZE,
|
||||
},
|
||||
"twenty-ninth": {
|
||||
"slug": "twenty-ninth-battle-map",
|
||||
@@ -279,6 +284,7 @@ MAP_CONFIGS = {
|
||||
"out": BATTLE_IMAGE_DIR / "twenty-ninth-battle-map.webp",
|
||||
"before": BATTLE_IMAGE_DIR / "twenty-ninth-battle-map.svg",
|
||||
"seed": 240984,
|
||||
"tile_size": LARGE_MAP_TILE_SIZE,
|
||||
},
|
||||
"thirtieth": {
|
||||
"slug": "thirtieth-battle-map",
|
||||
@@ -288,6 +294,7 @@ MAP_CONFIGS = {
|
||||
"out": BATTLE_IMAGE_DIR / "thirtieth-battle-map.webp",
|
||||
"before": BATTLE_IMAGE_DIR / "thirtieth-battle-map.svg",
|
||||
"seed": 240994,
|
||||
"tile_size": LARGE_MAP_TILE_SIZE,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -846,8 +853,9 @@ def add_subtle_grid_and_grade(canvas: Image.Image, terrain: list[list[str]]) ->
|
||||
|
||||
|
||||
def build_map(config: dict[str, object]) -> Image.Image:
|
||||
global RNG
|
||||
global RNG, TILE
|
||||
RNG = random.Random(int(config["seed"]))
|
||||
TILE = int(config.get("tile_size", DEFAULT_TILE_SIZE))
|
||||
terrain = parse_battle_terrain(str(config["terrain_export"]))
|
||||
ally_positions_export = config["ally_positions_export"]
|
||||
units = parse_battle_units(str(config["units_export"]), None if ally_positions_export is None else str(ally_positions_export))
|
||||
@@ -920,10 +928,15 @@ def main() -> None:
|
||||
parser.add_argument("--before", type=Path)
|
||||
parser.add_argument("--comparison", type=Path)
|
||||
parser.add_argument("--preview", type=Path)
|
||||
parser.add_argument("--tile-size", type=int)
|
||||
parser.add_argument("--webp-quality", type=int, default=90)
|
||||
args = parser.parse_args()
|
||||
|
||||
config = MAP_CONFIGS[args.map]
|
||||
config = dict(MAP_CONFIGS[args.map])
|
||||
if args.tile_size is not None:
|
||||
if args.tile_size < 160:
|
||||
raise ValueError("--tile-size must be 160 or greater")
|
||||
config["tile_size"] = args.tile_size
|
||||
out_path = args.out or Path(config["out"])
|
||||
before_path = args.before or Path(config["before"])
|
||||
comparison_path = args.comparison or (DOCS_DIR / f"{config['slug']}-handpaint-before-after.png")
|
||||
@@ -950,6 +963,7 @@ def main() -> None:
|
||||
print(
|
||||
{
|
||||
"map": args.map,
|
||||
"tile_size": TILE,
|
||||
"out": str(out_path),
|
||||
"size": after.size,
|
||||
"comparison": str(comparison_path),
|
||||
|
||||
Reference in New Issue
Block a user