Effect Matrix * Better colors

This commit is contained in:
Fabian Schlenz 2020-04-28 17:46:23 +02:00
parent c6b2a8a1d0
commit f8b6f5cc02
2 changed files with 38 additions and 0 deletions

View File

@ -48,6 +48,15 @@ public:
RandomMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
};
class ColumnMatrixEffectColumn : public MatrixEffectColumn {
protected:
uint8_t _hue;
CRGB _getColor(uint8_t height) override;
void restart(bool completely_random) override;
public:
ColumnMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
};
class MatrixEffectBase : public Effect {
protected:
MatrixEffectColumn** _columns;
@ -86,3 +95,11 @@ public:
RandomMatrixEffect();
String get_name() override { return "random_matrix"; }
};
class ColumnMatrixEffect : public MatrixEffectBase {
protected:
void _create() override;
public:
ColumnMatrixEffect();
String get_name() override { return "column_matrix"; }
};

View File

@ -127,6 +127,18 @@ void RandomMatrixEffectColumn::restart(bool completely_random) {
_hue = random8();
}
CRGB ColumnMatrixEffectColumn::_getColor(uint8_t i) {
CRGB color;
uint8_t dist = abs(length / 2 - i);
color = CHSV(_hue, 255, 255 - dist * 5);
return color;
}
void ColumnMatrixEffectColumn::restart(bool completely_random) {
MatrixEffectColumn::restart(completely_random);
_hue = random8();
}
@ -174,6 +186,15 @@ void RainbowMatrixEffect::_create() {
for (int i=0; i<_count; i++) _columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
}
ColumnMatrixEffect::ColumnMatrixEffect() {
_init();
_create();
}
void ColumnMatrixEffect::_create() {
for (int i=0; i<_count; i++) _columns[i] = new ColumnMatrixEffectColumn(window, MatrixEffectColumn::DIR_NORTH);
}
MatrixEffectBase::~MatrixEffectBase() {
_delete();
}