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 401 of file Painter.cpp.

404 {
405
406 led_rope->RawBeginDraw();
407 int total_counted = 0;
408
409 float r, g, b;
410 r = g = b = 0;
411
412 for (int i = 0; i < KeyboardState::kNumKeys; ++i) {
413 const Key& key = keyboard.keys_[i];
414
415
416 if (key.curr_color_.v_ > 0.0f) {
417 const Color3i rgb = key.curr_color_.ToRGB();
418 r += rgb.r_;
419 g += rgb.g_;
420 b += rgb.b_;
421 ++total_counted;
422 }
423 }
424
425 float denom = total_counted ? total_counted : 1;
426 r /= denom;
427 g /= denom;
428 b /= denom;
429
430
431 const Color3i rgb(r, g, b);
432
433 for (int i = 0; i < led_column_table_length; ++i) {
434 const int n = led_column_table[i];
435 for (int i = 0; i < n; ++i) {
436 led_rope->RawDrawPixel(rgb);
437 }
438 }
439 led_rope->RawCommitDraw();
440}
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: