The *matrix effects now are all derived from MatrixEffectBase class. Also, you can now set the amount of columns for these effects.
This commit is contained in:
@ -136,37 +136,61 @@ void RandomMatrixEffectColumn::restart(bool completely_random) {
|
||||
|
||||
|
||||
|
||||
boolean MatrixEffect::can_be_shown_with_clock() { return true; };
|
||||
boolean MatrixEffectBase::can_be_shown_with_clock() { return true; };
|
||||
|
||||
void MatrixEffectBase::_init() {
|
||||
_count = _get_count();
|
||||
_columns = new MatrixEffectColumn* [_count];
|
||||
}
|
||||
|
||||
uint8_t MatrixEffectBase::_get_count() { return settings.effects.matrix.count; }
|
||||
|
||||
MatrixEffect::MatrixEffect() {
|
||||
_columns = new MatrixEffectColumn* [window->width];
|
||||
for (int i=0; i<window->width; i++) _columns[i] = new MatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||
_init();
|
||||
_create();
|
||||
}
|
||||
|
||||
void MatrixEffect::_create() {
|
||||
for (int i=0; i<_count; i++) _columns[i] = new MatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||
}
|
||||
|
||||
RandomMatrixEffect::RandomMatrixEffect() {
|
||||
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
|
||||
for (int i=0; i<window->width; i++) {
|
||||
delete _columns[i];
|
||||
_columns[i] = new RandomMatrixEffectColumn(window, random8(4), true);
|
||||
}
|
||||
_init();
|
||||
_create();
|
||||
}
|
||||
|
||||
void RandomMatrixEffect::_create() {
|
||||
for (int i=0; i<_count; i++) _columns[i] = new RandomMatrixEffectColumn(window, random8(4), true);
|
||||
}
|
||||
|
||||
uint8_t RandomMatrixEffect::_get_count() { return settings.effects.matrix.random_count; }
|
||||
|
||||
RainbowMatrixEffect::RainbowMatrixEffect() {
|
||||
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
|
||||
for (int i=0; i<window->width; i++) {
|
||||
delete _columns[i];
|
||||
_columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||
}
|
||||
_init();
|
||||
_create();
|
||||
}
|
||||
|
||||
MatrixEffect::~MatrixEffect() {
|
||||
for (int i=0; i<window->width; i++) {
|
||||
void RainbowMatrixEffect::_create() {
|
||||
for (int i=0; i<_count; i++) _columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||
}
|
||||
|
||||
MatrixEffectBase::~MatrixEffectBase() {
|
||||
_delete();
|
||||
}
|
||||
|
||||
void MatrixEffectBase::_delete() {
|
||||
for (int i=0; i<_count; i++) {
|
||||
delete _columns[i];
|
||||
}
|
||||
delete[] _columns;
|
||||
}
|
||||
|
||||
void MatrixEffect::loop(uint16_t ms) {
|
||||
void MatrixEffectBase::loop(uint16_t ms) {
|
||||
if (_count != _get_count()) {
|
||||
_delete();
|
||||
_init();
|
||||
_create();
|
||||
}
|
||||
window->clear();
|
||||
for (int i=0; i<window->width; i++) _columns[i]->loop(ms);
|
||||
for (int i=0; i<_count; i++) _columns[i]->loop(ms);
|
||||
}
|
||||
|
Reference in New Issue
Block a user