pitrix/src/effect_twirl.cpp

13 lines
526 B
C++
Raw Normal View History

#include "effect_twirl.h"
#include "functions.h"
void TwirlEffect::loop() {
for (int x=0; x<window->width; x++) for (int y=0; y<window->height; y++) {
2019-06-07 04:24:16 +00:00
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;
CRGB color(CHSV(angle, (brightness<<5) & 0xFF, 255));
window->setPixel(x, y, &color);
2019-06-07 04:24:16 +00:00
}
angleOffset += 1;
}