Effect dvd now with subpixel rendering.
This commit is contained in:
parent
ef57c5ea2e
commit
8bcee1871f
@ -4,8 +4,8 @@
|
|||||||
class DvdEffect : public Effect {
|
class DvdEffect : public Effect {
|
||||||
private:
|
private:
|
||||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||||
uint8_t _x = 0;
|
saccum78 _x = 0;
|
||||||
uint8_t _y = 0;
|
saccum78 _y = 0;
|
||||||
int8_t _x_dir = 1;
|
int8_t _x_dir = 1;
|
||||||
int8_t _y_dir = 1;
|
int8_t _y_dir = 1;
|
||||||
CRGB _color;
|
CRGB _color;
|
||||||
|
@ -3,27 +3,41 @@
|
|||||||
|
|
||||||
void DvdEffect::loop(uint16_t ms) {
|
void DvdEffect::loop(uint16_t ms) {
|
||||||
bool dir_changed = false;
|
bool dir_changed = false;
|
||||||
EVERY_N_MILLISECONDS( 250 ) {
|
|
||||||
_x += _x_dir;
|
|
||||||
_y += _y_dir;
|
|
||||||
|
|
||||||
if (_x == 0 || _x + settings.effects.dvd.width >= window->width) {
|
_x += _x_dir * settings.effects.dvd.speed;
|
||||||
_x_dir = -_x_dir;
|
_y += _y_dir * settings.effects.dvd.speed;
|
||||||
dir_changed = true;
|
|
||||||
}
|
if (_x <= 0) {
|
||||||
if (_y == 0 || _y + settings.effects.dvd.height >= window->height) {
|
_x = -_x;
|
||||||
_y_dir = -_y_dir;
|
_x_dir = -_x_dir;
|
||||||
dir_changed = true;
|
dir_changed = true;
|
||||||
}
|
//LOGln("speed: %d", settings.effects.dvd.speed);
|
||||||
|
} else if (_x + (settings.effects.dvd.width << 8) >= (window->width << 8)) {
|
||||||
|
_x -= 2*settings.effects.dvd.speed;
|
||||||
|
_x_dir = -_x_dir;
|
||||||
|
dir_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_y <= 0) {
|
||||||
|
_y = -_y;
|
||||||
|
_y_dir = -_y_dir;
|
||||||
|
dir_changed = true;
|
||||||
|
} else if (_y + (settings.effects.dvd.height << 8) >= (window->height << 8)) {
|
||||||
|
_y -= 2*settings.effects.dvd.speed;
|
||||||
|
_y_dir = -_y_dir;
|
||||||
|
dir_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->clear();
|
window->clear();
|
||||||
|
|
||||||
for (int x=0; x<settings.effects.dvd.width; x++) for (int y=0; y<settings.effects.dvd.height; y++) {
|
|
||||||
window->setPixel(_x + x, _y + y, (CRGB*)&_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dir_changed) _color = (CRGB)CHSV(random8(), 255, 255);
|
if (dir_changed) _color = (CRGB)CHSV(random8(), 255, 255);
|
||||||
|
|
||||||
|
for (int x=0; x<settings.effects.dvd.width; x++) for (int y=0; y<settings.effects.dvd.height; y++) {
|
||||||
|
window->setSubPixel(_x + (x<<8), _y + (y<<8), (CRGB*)&_color);
|
||||||
|
}
|
||||||
|
for (int x=1; x<settings.effects.dvd.width; x++) for (int y=1; y<settings.effects.dvd.height; y++) {
|
||||||
|
window->setPixel((_x>>8) + x, (_y>>8) + y, (CRGB*)&_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DvdEffect::can_be_shown_with_clock() { return true; }
|
bool DvdEffect::can_be_shown_with_clock() { return true; }
|
||||||
|
Loading…
Reference in New Issue
Block a user