From ed38ec64bd0ac2c1bb840294442144b442de0aaf Mon Sep 17 00:00:00 2001 From: profezzorn Date: Fri, 15 Dec 2023 00:55:26 -0600 Subject: [PATCH] simplify Gradient<> --- styles/gradient.h | 51 ++--------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/styles/gradient.h b/styles/gradient.h index 92bdf1a08..960023eed 100644 --- a/styles/gradient.h +++ b/styles/gradient.h @@ -9,55 +9,8 @@ // Gradient, color A at base, B at tip. // Any number of colors can be put together into a gradient. -class BlaseBase; +#include "../functions/ramp.h" -template -class GradientHelper {}; - -template -class GradientHelper { -public: - static const size_t size = 0; - void run(BladeBase* blade) { a_.run(blade); } - PONUA A a_; - auto get(int led, int partition) -> decltype(a_.getColor(led)) { - return a_.getColor(led); - } -}; - -template -class GradientHelper { -public: - static const size_t size = GradientHelper::size + 1; - void run(BladeBase* blade) { - a_.run(blade); - b_.run(blade); - } - PONUA A a_; - PONUA GradientHelper b_; - auto get(int led, int partition) -> decltype(MixColors(a_.getColor(0), b_.get(0,0), 1, 1)) { - if (partition <= 16384) { - return MixColors(a_.getColor(led), b_.a_.getColor(led), partition, 14); - } else { - return b_.get(led, partition - 16384); - } - } -}; - -template -class Gradient { -public: - void run(BladeBase* blade) { - colors_.run(blade); - mul_ = (GradientHelper::size << 14) / (blade->num_leds() - 1); - } -private: - PONUA GradientHelper colors_; - int mul_; -public: - auto getColor(int led) -> decltype(colors_.get(led, led * mul_)) { - return colors_.get(led, led * mul_); - } -}; +template using Gradient = Mix; #endif