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

362 {
363
364 led_rope->RawBeginDraw();
365
366 uint32_t skipped_lights = 0;
367 for (int i = 0; i < led_column_table_length; ++i) {
368 const Key& key = keyboard.keys_[i];
369 uint32_t painted_lights = 0;
370
371 // % of lights that are active.
372 const float active_lights_factor = led_column_table[i] * sqrt(key.curr_color_.v_);
373 const float inactive_lights_factor = 1.0f - active_lights_factor;
374 const float taper_point_1 = inactive_lights_factor / 2.0f;
375 const float taper_point_2 = taper_point_1 + active_lights_factor;
376
377 const int taper_idx_1 = static_cast<int>(floor(taper_point_1 * led_column_table[i]));
378 const int taper_idx_2 = static_cast<int>(floor(taper_point_2 * led_column_table[i]));
379
380 const Color3i c = key.curr_color_.ToRGB();
381
382 for (int i = 0; i < taper_idx_1 / 2; ++i) {
383 led_rope->RawDrawPixel(Color3i::Black());
384 painted_lights++;
385 }
386
387 int length = taper_idx_2 - taper_idx_1;
388 for (int i = 0; i < min(200, length); ++i) {
389 led_rope->RawDrawPixel(c);
390 painted_lights++;
391 }
392
393 length = led_column_table[i] - taper_idx_2;
394 for (int i = 0; i < length; ++i) {
395 led_rope->RawDrawPixel(Color3i::Black());
396 painted_lights++;
397 }
398 skipped_lights += MAX(0, static_cast<int32_t>(led_column_table[i]) - static_cast<int32_t>(painted_lights));
399 }
400
401 for (uint32_t i = 0; i < skipped_lights; ++i) {
402 led_rope->RawDrawPixel(Color3i::Black());
403 }
404
405 led_rope->RawCommitDraw();
406}
Key keys_[kNumKeys]
Definition Keyboard.h:103
virtual void RawDrawPixel(const Color3i &c)=0
virtual void RawCommitDraw()=0
virtual void RawBeginDraw()=0
UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
#define MAX(a, b)
Definition math_macros.h:11
T floor(T value)
Definition math.h:11
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_, length(), 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: