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) {
|
||||
blob.setPos(random(140));
|
||||
blob.setBrightness(random(255));
|
||||
if (random(255) % 2) {
|
||||
if (random(254) % 2) {
|
||||
blob.setVelocity(-1);
|
||||
}
|
||||
});
|
||||
@ -26,7 +26,7 @@ void SolidAnimation::handleEvent(const InputEvent& evt) {
|
||||
m_curColor = nextColor;
|
||||
m_horizontal = !m_horizontal;
|
||||
} else if (evt.intent == InputEvent::Beat) {
|
||||
m_isRandom = false;
|
||||
//m_isRandom = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,13 +34,11 @@ void SolidAnimation::loop() {
|
||||
if (!m_isRandom) {
|
||||
randomize();
|
||||
}
|
||||
m_red.update(15);
|
||||
m_green.update(15);
|
||||
m_blue.update(15);
|
||||
EVERY_N_MILLIS(16) {
|
||||
m_changePct.update(12);
|
||||
}
|
||||
EVERY_N_MILLIS(6) {
|
||||
EVERY_N_MILLIS(20) {
|
||||
m_changePct.update(1);
|
||||
m_red.update(1);
|
||||
m_green.update(1);
|
||||
m_blue.update(1);
|
||||
CRGB rgb{m_red, m_green, m_blue};
|
||||
CHSV hsv = rgb2hsv_approximate(rgb);
|
||||
m_blobs.forEach([=](Blob& blob) {
|
||||
@ -56,15 +54,17 @@ void SolidAnimation::loop() {
|
||||
void SolidAnimation::render(Display* dpy) const {
|
||||
PerfCounter _("solidRender");
|
||||
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);
|
||||
if (frame == 255) {
|
||||
Surface(dpy, {0, 0}, {255, 255}) = color;
|
||||
if (F_LIKELY(frame == 255)) {
|
||||
Surface(dpy, {0, 0}, {255, 255}) = color.nscale8(10);
|
||||
} else {
|
||||
uint8_t cutoff = (frame / 2);
|
||||
uint8_t rotation = m_horizontal ? 0 : 128;
|
||||
Surface(dpy, {0, 0}, {128 - cutoff, 255}, rotation) = m_prevColor;
|
||||
Surface(dpy, {128 - cutoff, 0}, {128 + cutoff, 255}, rotation) = color;
|
||||
Surface(dpy, {128 + cutoff, 0}, {255, 255}, rotation) = m_prevColor;
|
||||
Surface(dpy, {0, 0}, {128 - cutoff, 255}, rotation) = scaledPrev;
|
||||
Surface(dpy, {128 - cutoff, 0}, {128 + cutoff, 255}, rotation) = scaledPrev;
|
||||
Surface(dpy, {128 + cutoff, 0}, {255, 255}, rotation) = scaledPrev;
|
||||
}
|
||||
m_blobs.render(dpy);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user