Added Effect TwirlEffect (WIP).
This commit is contained in:
parent
2e595bda17
commit
7b9efa1357
16
effects.h
16
effects.h
@ -413,3 +413,19 @@ class CycleEffect : public Effect {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class TwirlEffect : public Effect {
|
||||
private:
|
||||
uint8_t angleOffset = 0;
|
||||
double center_x = 8;
|
||||
double center_y = 8;
|
||||
public:
|
||||
void loop() {
|
||||
for (int x=0; x<window.w; x++) for (int y=0; y<window.h; y++) {
|
||||
uint8_t angle = (x==center_x && y==center_y) ? 0 : atan2(y - center_y, x - center_x) / M_PI * 128 + 128 + angleOffset;
|
||||
uint8_t brightness = sqrt16((center_x - x) * (center_x - x) + (center_y - y) * (center_y - y)) & 0xFF;
|
||||
setPixel(window, x, y, CHSV(angle, (brightness<<5) & 0xFF, 255));
|
||||
}
|
||||
angleOffset += 1;
|
||||
}
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ SimpleList<Effect*>* cycle_effects;
|
||||
|
||||
#include "effects.h"
|
||||
|
||||
#define NUM_EFFECTS 11
|
||||
#define NUM_EFFECTS 12
|
||||
//EffectEntry effects[NUM_EFFECTS];
|
||||
Sinematrix3 sinematrix3;
|
||||
BigClock big_clock;
|
||||
@ -66,6 +66,7 @@ SingleDynamic single_dynamic;
|
||||
MultiDynamic multi_dynamic;
|
||||
MatrixEffect matrix;
|
||||
CycleEffect effect_cycle;
|
||||
TwirlEffect effect_twirl;
|
||||
|
||||
EffectEntry effects[NUM_EFFECTS] = {
|
||||
{"sinematrix3", (Effect *)&sinematrix3},
|
||||
@ -79,6 +80,7 @@ EffectEntry effects[NUM_EFFECTS] = {
|
||||
{"multi_dynamic", (Effect *)&multi_dynamic},
|
||||
{"matrix", (Effect *)&matrix},
|
||||
{"cycle", (Effect *)&effect_cycle},
|
||||
{"twirl", (Effect *)&effect_twirl},
|
||||
};
|
||||
|
||||
void setup_cycle_effects() {
|
||||
|
Loading…
Reference in New Issue
Block a user