animations: solid: increase pre-blob color headroom, make color transitions much smoother
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
4a75e09792
commit
bbc01f7cea
@ -9,7 +9,7 @@ void SolidAnimation::randomize() {
|
|||||||
m_blobs.forEach([](Blob& blob) {
|
m_blobs.forEach([](Blob& blob) {
|
||||||
blob.setPos(random(140));
|
blob.setPos(random(140));
|
||||||
blob.setBrightness(random(255));
|
blob.setBrightness(random(255));
|
||||||
if (random(255) % 2) {
|
if (random(254) % 2) {
|
||||||
blob.setVelocity(-1);
|
blob.setVelocity(-1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -26,7 +26,7 @@ void SolidAnimation::handleEvent(const InputEvent& evt) {
|
|||||||
m_curColor = nextColor;
|
m_curColor = nextColor;
|
||||||
m_horizontal = !m_horizontal;
|
m_horizontal = !m_horizontal;
|
||||||
} else if (evt.intent == InputEvent::Beat) {
|
} else if (evt.intent == InputEvent::Beat) {
|
||||||
m_isRandom = false;
|
//m_isRandom = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,13 +34,11 @@ void SolidAnimation::loop() {
|
|||||||
if (!m_isRandom) {
|
if (!m_isRandom) {
|
||||||
randomize();
|
randomize();
|
||||||
}
|
}
|
||||||
m_red.update(15);
|
EVERY_N_MILLIS(20) {
|
||||||
m_green.update(15);
|
m_changePct.update(1);
|
||||||
m_blue.update(15);
|
m_red.update(1);
|
||||||
EVERY_N_MILLIS(16) {
|
m_green.update(1);
|
||||||
m_changePct.update(12);
|
m_blue.update(1);
|
||||||
}
|
|
||||||
EVERY_N_MILLIS(6) {
|
|
||||||
CRGB rgb{m_red, m_green, m_blue};
|
CRGB rgb{m_red, m_green, m_blue};
|
||||||
CHSV hsv = rgb2hsv_approximate(rgb);
|
CHSV hsv = rgb2hsv_approximate(rgb);
|
||||||
m_blobs.forEach([=](Blob& blob) {
|
m_blobs.forEach([=](Blob& blob) {
|
||||||
@ -56,15 +54,17 @@ void SolidAnimation::loop() {
|
|||||||
void SolidAnimation::render(Display* dpy) const {
|
void SolidAnimation::render(Display* dpy) const {
|
||||||
PerfCounter _("solidRender");
|
PerfCounter _("solidRender");
|
||||||
CRGB color(m_red.value(), m_green.value(), m_blue.value());
|
CRGB color(m_red.value(), m_green.value(), m_blue.value());
|
||||||
|
CRGB scaledPrev = m_prevColor;
|
||||||
|
scaledPrev = color.nscale8(30);
|
||||||
uint8_t frame = ease8InOutApprox(m_changePct);
|
uint8_t frame = ease8InOutApprox(m_changePct);
|
||||||
if (frame == 255) {
|
if (F_LIKELY(frame == 255)) {
|
||||||
Surface(dpy, {0, 0}, {255, 255}) = color;
|
Surface(dpy, {0, 0}, {255, 255}) = color.nscale8(10);
|
||||||
} else {
|
} else {
|
||||||
uint8_t cutoff = (frame / 2);
|
uint8_t cutoff = (frame / 2);
|
||||||
uint8_t rotation = m_horizontal ? 0 : 128;
|
uint8_t rotation = m_horizontal ? 0 : 128;
|
||||||
Surface(dpy, {0, 0}, {128 - cutoff, 255}, rotation) = m_prevColor;
|
Surface(dpy, {0, 0}, {128 - cutoff, 255}, rotation) = scaledPrev;
|
||||||
Surface(dpy, {128 - cutoff, 0}, {128 + cutoff, 255}, rotation) = color;
|
Surface(dpy, {128 - cutoff, 0}, {128 + cutoff, 255}, rotation) = scaledPrev;
|
||||||
Surface(dpy, {128 + cutoff, 0}, {255, 255}, rotation) = m_prevColor;
|
Surface(dpy, {128 + cutoff, 0}, {255, 255}, rotation) = scaledPrev;
|
||||||
}
|
}
|
||||||
m_blobs.render(dpy);
|
m_blobs.render(dpy);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user