Skip to content

Commit

Permalink
Merge pull request #3373 from Aircoookie/ripple-tweak
Browse files Browse the repository at this point in the history
2D Ripple and Meteor effect tweak
  • Loading branch information
softhack007 committed Sep 17, 2023
2 parents 282d58a + c7d45c2 commit 527e3d6
Show file tree
Hide file tree
Showing 3 changed files with 998 additions and 997 deletions.
18 changes: 10 additions & 8 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ uint16_t mode_meteor() {
{
byte meteorTrailDecay = 128 + random8(127);
trail[i] = scale8(trail[i], meteorTrailDecay);
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, false, 0, trail[i]));
SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(i, true, false, 0), trail[i]));
}
}

Expand All @@ -2281,12 +2281,12 @@ uint16_t mode_meteor() {
index -= SEGLEN;
}
trail[index] = 240;
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0, 255));
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0));
}

return FRAMETIME;
}
static const char _data_FX_MODE_METEOR[] PROGMEM = "Meteor@!,Trail length;!;!";
static const char _data_FX_MODE_METEOR[] PROGMEM = "Meteor@!,Trail length;!,!;!;1";


// smooth meteor effect
Expand All @@ -2309,7 +2309,7 @@ uint16_t mode_meteor_smooth() {
trail[i] += change;
if (trail[i] > 245) trail[i] = 0;
if (trail[i] > 240) trail[i] = 240;
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(i, true, false, 0, trail[i]));
SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(i, true, false, 0), trail[i]));
}
}

Expand All @@ -2320,13 +2320,13 @@ uint16_t mode_meteor_smooth() {
index -= SEGLEN;
}
trail[index] = 240;
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0, 255));
SEGMENT.setPixelColor(index, SEGMENT.color_from_palette(index, true, false, 0));
}

SEGENV.step += SEGMENT.speed +1;
return FRAMETIME;
}
static const char _data_FX_MODE_METEOR_SMOOTH[] PROGMEM = "Meteor Smooth@!,Trail length;!;!";
static const char _data_FX_MODE_METEOR_SMOOTH[] PROGMEM = "Meteor Smooth@!,Trail length;!,!;!;1";


//Railway Crossing / Christmas Fairy lights
Expand Down Expand Up @@ -2400,9 +2400,10 @@ uint16_t ripple_base()

#ifndef WLED_DISABLE_2D
if (SEGMENT.is2D()) {
propI /= 2;
uint16_t cx = rippleorigin >> 8;
uint16_t cy = rippleorigin & 0xFF;
uint8_t mag = scale8(cubicwave8((propF>>2)), amp);
uint8_t mag = scale8(sin8((propF>>2)), amp);
if (propI > 0) SEGMENT.draw_circle(cx, cy, propI, color_blend(SEGMENT.getPixelColorXY(cx + propI, cy), col, mag));
} else
#endif
Expand All @@ -2418,7 +2419,7 @@ uint16_t ripple_base()
ripplestate += rippledecay;
ripples[i].state = (ripplestate > 254) ? 0 : ripplestate;
} else {//randomly create new wave
if (random16(IBN + 10000) <= SEGMENT.intensity) {
if (random16(IBN + 10000) <= (SEGMENT.intensity >> (SEGMENT.is2D()*3))) {
ripples[i].state = 1;
ripples[i].pos = SEGMENT.is2D() ? ((random8(SEGENV.virtualWidth())<<8) | (random8(SEGENV.virtualHeight()))) : random16(SEGLEN);
ripples[i].color = random8(); //color
Expand All @@ -2434,6 +2435,7 @@ uint16_t ripple_base()
uint16_t mode_ripple(void) {
if (SEGLEN == 1) return mode_static();
if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1));
else SEGMENT.fade_out(250);
return ripple_base();
}
static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,Wave #,,,,,Overlay;,!;!;12";
Expand Down
2 changes: 1 addition & 1 deletion wled00/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ function updateSelectedPalette(s)
if (s > 1 && s < 6) {
cd[0].classList.remove('hide'); // * Color 1
if (s > 2) cd[1].classList.remove('hide'); // * Color 1 & 2
if (s == 5) cd[2].classList.remove('hide'); // all colors
if (s > 3) cd[2].classList.remove('hide'); // all colors
} else {
for (let i of cd) if (i.dataset.hide == '1') i.classList.add('hide');
}
Expand Down
Loading

0 comments on commit 527e3d6

Please sign in to comment.