Effect Matrix * Better colors
This commit is contained in:
parent
c6b2a8a1d0
commit
f8b6f5cc02
@ -48,6 +48,15 @@ public:
|
|||||||
RandomMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
|
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 {
|
class MatrixEffectBase : public Effect {
|
||||||
protected:
|
protected:
|
||||||
MatrixEffectColumn** _columns;
|
MatrixEffectColumn** _columns;
|
||||||
@ -86,3 +95,11 @@ public:
|
|||||||
RandomMatrixEffect();
|
RandomMatrixEffect();
|
||||||
String get_name() override { return "random_matrix"; }
|
String get_name() override { return "random_matrix"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ColumnMatrixEffect : public MatrixEffectBase {
|
||||||
|
protected:
|
||||||
|
void _create() override;
|
||||||
|
public:
|
||||||
|
ColumnMatrixEffect();
|
||||||
|
String get_name() override { return "column_matrix"; }
|
||||||
|
};
|
@ -127,6 +127,18 @@ void RandomMatrixEffectColumn::restart(bool completely_random) {
|
|||||||
_hue = random8();
|
_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);
|
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() {
|
MatrixEffectBase::~MatrixEffectBase() {
|
||||||
_delete();
|
_delete();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user