Closed fweiss closed 2 months ago
This is related to #10. Maybe just hack to data reduction and then deal with the code duplication?
An outline of the IndexedColor::drawFrame(Frame&) function:
Maybe we can do a function relay like this:
in subclass:
void drawFrame(Frame& frame) {
drawFrame<ColorIndex>(frame);
}
and the IndexColorAnimation, create a function template:
template<ColorIndexEnum>
void drawFrame(Frame& frame) {
// here we have access to the particular ColorIndex for the subclass
}
The above mentioned function template approach works.
So we reduced the index color initialization code. Static initialization of pixelIndexes[][] works best instead of std::vector>. Also using ColorIndex enum to ensure that array bounds are safe. But the enum is tricky. We tried to put the drawFrame(Frame&) in the base class, but had to repeat it in each subclass to handle the subclass's particular enum.
We tried several approaches: templates. helper classes, helper functions. We want to keep the enum as index type safety, but the drawFrame lookups can be the underlying uint. The main problem seems to be with the colorMap which is std::map<ColorIndex,uint32_t>, where ColorIndex is peculiar to the subclass. We also don't want to have too much boilerplate in the derived classes.