Re-organized Animation code to move from multiple different constructors to one constructor and a handfull of setters for options.
This commit is contained in:
@ -43,7 +43,7 @@ class Animation {
|
||||
uint8_t* animation_data;
|
||||
CRGB* colors;
|
||||
CRGB* fgColor;
|
||||
CRGB* bgColor;
|
||||
CRGB* bgColor = new CRGB(0x000000);
|
||||
int8_t xOffset = 0;
|
||||
int8_t yOffset = 0;
|
||||
uint8_t startFrame;
|
||||
@ -54,34 +54,17 @@ class Animation {
|
||||
void drawPixel(int index, CRGB* color);
|
||||
uint16_t getFrameDelay(int frame);
|
||||
public:
|
||||
Animation(AnimationData* d) : Animation(d, new CRGB(0x000000), 0, 0) {};
|
||||
Animation(AnimationData* d, CRGB* bg_color): Animation(d, bg_color, 0, 0) {};
|
||||
Animation(AnimationData* d, CRGB* bg_color, int8_t xOffset, int8_t yOffset);
|
||||
Animation(AnimationData* d);
|
||||
void setFgColor(CRGB*);
|
||||
void setBgColor(CRGB* bg_color);
|
||||
bool invert();
|
||||
void setOffsets(int8_t x, int8_t y);
|
||||
void setStartFrame(uint8_t sf);
|
||||
void setEndFrame(uint8_t ef);
|
||||
void setFrameRange(uint8_t sf, uint8_t ef);
|
||||
void setSingleFrame(uint8_t frame);
|
||||
virtual ~Animation();
|
||||
void draw();
|
||||
void drawFrame();
|
||||
virtual bool advance();
|
||||
};
|
||||
|
||||
class AnimationSlice : public Animation {
|
||||
public:
|
||||
AnimationSlice(AnimationData* d, uint8_t start, uint8_t end) : AnimationSlice(d, start, end, new CRGB(0x000000), 0, 0) {};
|
||||
AnimationSlice(AnimationData* d, uint8_t start, uint8_t end, CRGB* color) : AnimationSlice(d, start, end, color, 0, 0) {};
|
||||
AnimationSlice(AnimationData* d, uint8_t start, uint8_t end, CRGB* color, int8_t x, int8_t y);
|
||||
};
|
||||
|
||||
class Image : public AnimationSlice {
|
||||
public:
|
||||
Image(AnimationData* d) : AnimationSlice(d, 0, 0, new CRGB(0x000000), 0, 0) {};
|
||||
Image(AnimationData* d, CRGB* color) : AnimationSlice(d, 0, 0, color, 0, 0) {};
|
||||
Image(AnimationData* d, CRGB* color, int8_t x, int8_t y) : AnimationSlice(d, 0, 0, color, x, y) {};
|
||||
};
|
||||
|
||||
class Sprite : public Image {
|
||||
protected:
|
||||
virtual CRGB* getColor(uint8_t color_index);
|
||||
public:
|
||||
void setFgColor(CRGB c);
|
||||
void setBgColor(CRGB c);
|
||||
void setColors(CRGB c1, CRGB c2);
|
||||
};
|
||||
|
Reference in New Issue
Block a user