File size: 1,205 Bytes
ae853c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import os
from PIL import Image
from image_colorizer import recolor_plant, tint_seed
ASSETS_FOLDER = os.path.join(os.path.dirname(__file__), "assets_px")
SEED_TEMPLATE = os.path.join(ASSETS_FOLDER, "_seed_template.png")
def _stage_key(growth_stage_name):
return growth_stage_name.lower()
def generate_seed_image(seed_profile, growth_stage_name):
"""Render a specimen sprite for the given stage.
- Seed stage: the shared seed silhouette tinted to the strain's bud color.
- Seedling/Mature: the strain base sprite, shown as-is for starters, or
recolored through the leaf/bud masks for bred/cloned offspring.
"""
stage = _stage_key(growth_stage_name)
if stage == "seed":
template = Image.open(SEED_TEMPLATE).convert("RGBA")
return tint_seed(template, seed_profile.bud_color)
path = os.path.join(ASSETS_FOLDER, f"{seed_profile.base_image_name}_{stage}.png")
if not os.path.exists(path):
raise FileNotFoundError(f"[MISSING SPRITE] {path}")
base_image = Image.open(path).convert("RGBA")
if seed_profile.is_starter:
return base_image
return recolor_plant(base_image, seed_profile.leaf_color, seed_profile.bud_color)
|