FastLED 3.9.15
Loading...
Searching...
No Matches

◆ PaintBrightSurprise()

void Painter::PaintBrightSurprise ( const KeyboardState & keyboard,
const int * led_column_table,
int led_column_table_length,
LedRopeInterface * led_rope )
staticprivate

Definition at line 408 of file Painter.cpp.

411 {
412
413 led_rope->RawBeginDraw();
414 int total_counted = 0;
415
416 float r, g, b;
417 r = g = b = 0;
418
419 for (int i = 0; i < KeyboardState::kNumKeys; ++i) {
420 const Key& key = keyboard.keys_[i];
421
422
423 if (key.curr_color_.v_ > 0.0f) {
424 const Color3i rgb = key.curr_color_.ToRGB();
425 r += rgb.r_;
426 g += rgb.g_;
427 b += rgb.b_;
428 ++total_counted;
429 }
430 }
431
432 float denom = total_counted ? total_counted : 1;
433 r /= denom;
434 g /= denom;
435 b /= denom;
436
437
438 const Color3i rgb(r, g, b);
439
440 for (int i = 0; i < led_column_table_length; ++i) {
441 const int n = led_column_table[i];
442 for (int i = 0; i < n; ++i) {
443 led_rope->RawDrawPixel(rgb);
444 }
445 }
446 led_rope->RawCommitDraw();
447}
static const int kNumKeys
Definition Keyboard.h:101
Key keys_[kNumKeys]
Definition Keyboard.h:103
virtual void RawDrawPixel(const Color3i &c)=0
virtual void RawCommitDraw()=0
virtual void RawBeginDraw()=0
uint8_t b_
Definition color.h:52
uint8_t g_
Definition color.h:52
uint8_t r_
Definition color.h:52
float v_
Definition color.h:98
Color3i ToRGB() const
Definition color.cpp:128
ColorHSV curr_color_
Definition Keyboard.h:48

References Color3i::b_, Key::curr_color_, Color3i::g_, KeyboardState::keys_, KeyboardState::kNumKeys, Color3i::r_, LedRopeInterface::RawBeginDraw(), LedRopeInterface::RawCommitDraw(), LedRopeInterface::RawDrawPixel(), ColorHSV::ToRGB(), and ColorHSV::v_.

Referenced by Paint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: