Open B-Reif opened 3 years ago
Hm, I haven't found a good time to fully wrap my head around how the tileset stuff fits in.
But I have a few quick thoughts on the handling of indexed data.
Rc<Palette>
so we don't need to deal with lifetime parameters.The validator should still check for out of bounds indices. But if it has a bug there won't be a crash, just some transparent pixels.
The one ugly spot would be the handling of background-layer or not. I think that info shouldn't be moved into the cel, so it must be handled somewhere else.
I'm opening this issue to explore how we can encode some existing panic/assert invariants in static typing. This is one design I'm considering:
Any invariant behavior around the pixel format (a palette must be present, etc) would be encoded in this single
ImageContent
enum. This would replace thePixelFormat
andPixels
enums, and additionally contain the dependent data. Cels and Tilesets would become generic over a pixel type.Cels and Tilesets also contain a lot of non-pixel metadata. Making these types generic would make it harder to work with all of the non-image content. I also considered a design where the pixel data would live in a separate map from the non-pixel metadata:
This indirection would allow users to use Tilesets and Cels from multiple files without regard for their pixel format.