Skip to content

Commit

Permalink
fix type bug in TrConcat
Browse files Browse the repository at this point in the history
  • Loading branch information
profezzorn committed Jan 6, 2022
1 parent 0c83c0b commit e8dc1d6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
43 changes: 43 additions & 0 deletions styles/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
#define SCOPED_PROFILER() do { } while(0)
#define NUM_BLADES 1

// clamp(x, a, b) makes sure that x is between a and b.
float clamp(float x, float a, float b) {
if (x < a) return a;
if (x > b) return b;
return x;
}

struct CONFIG { struct Preset* presets; size_t num_presets;};
CONFIG preset = { 0,0 };
CONFIG* current_config = &preset;
Expand Down Expand Up @@ -114,17 +121,24 @@ Monitoring monitor;
#include "blinking.h"
#include "clash.h"
#include "color_cycle.h"
#include "edit_mode.h"
#include "remap.h"
#include "stripes.h"
#include "../transitions/base.h"
#include "../transitions/join.h"
#include "../transitions/wipe.h"
#include "../transitions/delay.h"
#include "../transitions/concat.h"
#include "../transitions/fade.h"
#include "../transitions/instant.h"
#include "../transitions/random.h"
#include "../functions/blade_angle.h"
#include "../functions/twist_angle.h"
#include "../functions/swing_speed.h"
#include "../functions/wavlen.h"
#include "../functions/center_dist.h"
#include "../functions/effect_position.h"
#include "../functions/random.h"
#include "mix.h"
#include "strobe.h"
#include "hump_flicker.h"
Expand Down Expand Up @@ -520,6 +534,35 @@ void test_style4() {
> t5;
}

void TestCompileStyle() {
TestStyle<Layers<
Blue,
MultiTransitionEffectL<
TrRandom<
TrConcat<
TrInstant, AlphaL<RgbArg<BLAST_COLOR_ARG, Rgb<255, 255, 255>>,
Bump<Int<16384>, Int<6000>>>,
TrFade<50>, AlphaL<RgbArg<BLAST_COLOR_ARG, Rgb<255, 255, 255>>, Int<0>>,
TrWaveX<
Remap<
CenterDistF<EffectPosition<>>,
Stripes<1500, -2000, RgbArg<BLAST_COLOR_ARG, Rgb<255, 255, 255>>,
Mix<Int<2096>, Black,
RgbArg<BLAST_COLOR_ARG, Rgb<255, 255, 255>>>>>,
Int<160>, Int<100>, Int<300>, EffectPosition<>>>,
TrConcat<TrInstant,
AlphaL<RgbArg<BLAST_COLOR_ARG, Rgb<255, 255, 255>>,
Bump<EffectPosition<>, Scale<EffectRandomF<EFFECT_BLAST>,
Int<7000>, Int<10000>>>>,
TrFade<300>>,
TrWaveX<RgbArg<BLAST_COLOR_ARG, Rgb<255, 255, 255>>,
Scale<EffectRandomF<EFFECT_BLAST>, Int<100>, Int<400>>, Int<100>,
Scale<EffectRandomF<EFFECT_BLAST>, Int<100>, Int<400>>,
Scale<EffectRandomF<EFFECT_BLAST>, Int<28000>, Int<8000>>>>,
EFFECT_BLAST>,
InOutTrL<TrWipe<300>, TrWipeIn<500>>>> t1;
}

void testGetArg(const char* str, int arg, const char* expected) {
char tmp[1024];
fprintf(stderr, "testGetArg(%s, %d)\n", str, arg);
Expand Down
5 changes: 3 additions & 2 deletions transitions/concat.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ class TrConcat<A, INTERMEDIATE, B...> {
PONUA INTERMEDIATE intermediate_;
public:
template<class X, class Y>
auto getColor(const X& a, const Y& b, int led) -> decltype(MixColors(a_.getColor(a, intermediate_.getColor(led), led),
b_.getColor(intermediate_.getColor(led), b, led), 1,1)) {
auto getColor(const X& a, const Y& b, int led) -> decltype(
MixColors(b, MixColors(a_.getColor(a, intermediate_.getColor(led), led),
b_.getColor(intermediate_.getColor(led), b, led), 1,1), 1, 1)) {
if (done()) return b;
auto intermediate = intermediate_.getColor(led);
if (run_a_) {
Expand Down

0 comments on commit e8dc1d6

Please sign in to comment.