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

◆ VegasVisualizer()

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

Definition at line 353 of file Painter.cpp.

355 {
356
357 led_rope->RawBeginDraw();
358
359 uint32_t skipped_lights = 0;
360 for (int i = 0; i < led_column_table_length; ++i) {
361 const Key& key = keyboard.keys_[i];
362 uint32_t painted_lights = 0;
363
364 // % of lights that are active.
365 const float active_lights_factor = led_column_table[i] * sqrt(key.curr_color_.v_);
366 const float inactive_lights_factor = 1.0f - active_lights_factor;
367 const float taper_point_1 = inactive_lights_factor / 2.0f;
368 const float taper_point_2 = taper_point_1 + active_lights_factor;
369
370 const int taper_idx_1 = static_cast<int>(floor(taper_point_1 * led_column_table[i]));
371 const int taper_idx_2 = static_cast<int>(floor(taper_point_2 * led_column_table[i]));
372
373 const Color3i c = key.curr_color_.ToRGB();
374
375 for (int i = 0; i < taper_idx_1 / 2; ++i) {
376 led_rope->RawDrawPixel(Color3i::Black());
377 painted_lights++;
378 }
379
380 int length = taper_idx_2 - taper_idx_1;
381 for (int i = 0; i < min(200, length); ++i) {
382 led_rope->RawDrawPixel(c);
383 painted_lights++;
384 }
385
386 length = led_column_table[i] - taper_idx_2;
387 for (int i = 0; i < length; ++i) {
388 led_rope->RawDrawPixel(Color3i::Black());
389 painted_lights++;
390 }
391 skipped_lights += MAX(0, static_cast<int32_t>(led_column_table[i]) - static_cast<int32_t>(painted_lights));
392 }
393
394 for (uint32_t i = 0; i < skipped_lights; ++i) {
395 led_rope->RawDrawPixel(Color3i::Black());
396 }
397
398 led_rope->RawCommitDraw();
399}
Key keys_[kNumKeys]
Definition Keyboard.h:103
virtual void RawDrawPixel(const Color3i &c)=0
virtual void RawCommitDraw()=0
virtual void RawBeginDraw()=0
#define MAX(a, b)
Definition math_macros.h:4
static Color3i Black()
Definition color.h:9
float v_
Definition color.h:98
Color3i ToRGB() const
Definition color.cpp:128
ColorHSV curr_color_
Definition Keyboard.h:48

References Color3i::Black(), Key::curr_color_, KeyboardState::keys_, MAX, 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: