ColorForge & PolyCrafter
So, imagine a star map where each planet's color encodes its ecosystem. How would we structure the code to map those hues efficiently?
You want a palette table that’s basically a lookup table, so think of a dictionary where the key is the planet id and the value is an RGB tuple or hex string that represents its ecosystem hue.
```python
# planet_hues.py
planet_hues = {
"terra": "#3a8f46", # lush forest, deep green
"sahara": "#d4a642", # desert, warm sand
"abyss": "#0a2b5c", # deep ocean, midnight blue
"aurora": "#e3f7ff", # polar ice, icy cyan
# … add more
}
```
Then, wherever you need to paint a planet, just call `planet_hues[planet_id]`. If you need gradients, pre‑compute a list of intermediate colors and store them as a second level dictionary. Keep the hue data separate from the rendering code so you can tweak the palette without touching the drawing logic. Also, consider normalizing the hue values (0–360 degrees) if you plan to mix or interpolate colors later; it makes the math cleaner and your palette more flexible.