Skip to content

Commit

Permalink
Changed smearing back to original code, adjusted FX and some improvem…
Browse files Browse the repository at this point in the history
…ents

- smearing was introduced as a byproduct of my particle-system, it relies on smearing to be the way it was originally: this is in preparation of merging the particle system
- adjusted the FX to accomodate the change
- fixed bug in ripple FX not correctly blurring
- added smearing option to Lissajous
- improved blurring / smearing in crazy bees
- added fade option to Squared Swirl
  • Loading branch information
DedeHai committed Nov 22, 2024
1 parent 6a26944 commit cf4d1b6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
35 changes: 19 additions & 16 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2552,8 +2552,11 @@ static uint16_t ripple_base(uint8_t blurAmount = 0) {

uint16_t mode_ripple(void) {
if (SEGLEN == 1) return mode_static();
if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1));
else SEGMENT.fade_out(250);
if(SEGMENT.custom1 || SEGMENT.check2) // blur or overlay
SEGMENT.fade_out(250);
else
SEGMENT.fill(SEGCOLOR(1));

return ripple_base(SEGMENT.custom1>>1);
}
static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,Wave #,Blur,,,,Overlay;,!;!;12;c1=0";
Expand Down Expand Up @@ -4982,7 +4985,7 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa
SEGMENT.setPixelColorXY(i, beatsin8(SEGMENT.speed/8, 0, rows-1, 0, i*4 ), ColorFromPalette(SEGPALETTE, i*5+strip.now/17, beatsin8(5, 55, 255, 0, i*10), LINEARBLEND));
SEGMENT.setPixelColorXY(i, beatsin8(SEGMENT.speed/8, 0, rows-1, 0, i*4+128), ColorFromPalette(SEGPALETTE, i*5+128+strip.now/17, beatsin8(5, 55, 255, 0, i*10+128), LINEARBLEND));
}
SEGMENT.blur(SEGMENT.intensity>>(3-(SEGMENT.check1 * 2)), SEGMENT.check1);
SEGMENT.blur(SEGMENT.intensity>>(3-SEGMENT.check1), SEGMENT.check1);

return FRAMETIME;
} // mode_2Ddna()
Expand Down Expand Up @@ -5027,7 +5030,7 @@ uint16_t mode_2DDNASpiral() { // By: ldirko https://editor.soulma
SEGMENT.setPixelColorXY(x1, i, WHITE);
}
}
SEGMENT.blur(SEGMENT.custom1 >> (!SEGMENT.check1), SEGMENT.check1);
SEGMENT.blur(SEGMENT.custom1 >> 1, SEGMENT.check1);

return FRAMETIME;
} // mode_2DDNASpiral()
Expand Down Expand Up @@ -5057,7 +5060,7 @@ uint16_t mode_2DDrift() { // By: Stepko https://editor.soulmateli
SEGMENT.setPixelColorXY(colsCenter + mySin, rowsCenter + myCos, ColorFromPalette(SEGPALETTE, (i * 20) + t_20, 255, LINEARBLEND));
if (SEGMENT.check1) SEGMENT.setPixelColorXY(colsCenter + myCos, rowsCenter + mySin, ColorFromPalette(SEGPALETTE, (i * 20) + t_20, 255, LINEARBLEND));
}
SEGMENT.blur(SEGMENT.intensity>>((!SEGMENT.check2) * 3), SEGMENT.check2);
SEGMENT.blur(SEGMENT.intensity>>(3 - SEGMENT.check2), SEGMENT.check2);

return FRAMETIME;
} // mode_2DDrift()
Expand Down Expand Up @@ -5108,7 +5111,7 @@ uint16_t mode_2DFrizzles(void) { // By: Stepko https://editor.so
beatsin8(SEGMENT.intensity/8 - i, 0, rows - 1),
ColorFromPalette(SEGPALETTE, beatsin8(12, 0, 255), 255, LINEARBLEND));
}
SEGMENT.blur(SEGMENT.custom1 >> 3, SEGMENT.check1);
SEGMENT.blur(SEGMENT.custom1 >> (3 + SEGMENT.check1), SEGMENT.check1);
return FRAMETIME;
} // mode_2DFrizzles()
static const char _data_FX_MODE_2DFRIZZLES[] PROGMEM = "Frizzles@X frequency,Y frequency,Blur,,,Smear;;!;2";
Expand Down Expand Up @@ -5357,7 +5360,7 @@ uint16_t mode_2DJulia(void) { // An animated Julia set
y += dy;
}
if(SEGMENT.check1)
SEGMENT.blur(128, true);
SEGMENT.blur(100, true);

return FRAMETIME;
} // mode_2DJulia()
Expand Down Expand Up @@ -5386,11 +5389,11 @@ uint16_t mode_2DLissajous(void) { // By: Andrew Tuline
ylocn = (rows < 2) ? 1 : (map(2*ylocn, 0,511, 0,2*(rows-1)) +1) /2; // "rows > 1" is needed to avoid div/0 in map()
SEGMENT.setPixelColorXY((uint8_t)xlocn, (uint8_t)ylocn, SEGMENT.color_from_palette(strip.now/100+i, false, PALETTE_SOLID_WRAP, 0));
}
SEGMENT.blur(SEGMENT.custom1>>1);
SEGMENT.blur(SEGMENT.custom1>> (1 + SEGMENT.check1 * 2), SEGMENT.check1);

return FRAMETIME;
} // mode_2DLissajous()
static const char _data_FX_MODE_2DLISSAJOUS[] PROGMEM = "Lissajous@X frequency,Fade rate,Blur,,Speed;!;!;2;c1=0";
static const char _data_FX_MODE_2DLISSAJOUS[] PROGMEM = "Lissajous@X frequency,Fade rate,Blur,,Speed,Smear;!;!;2;c1=0";


///////////////////////
Expand Down Expand Up @@ -5661,7 +5664,7 @@ uint16_t mode_2DSindots(void) { // By: ldirko http
int y = sin8(t2 + i * SEGMENT.intensity/8)*(rows-1)/255; // max index now 255x15/255=15!
SEGMENT.setPixelColorXY(x, y, ColorFromPalette(SEGPALETTE, i * 255 / 13, 255, LINEARBLEND));
}
SEGMENT.blur(SEGMENT.custom2>>3, SEGMENT.check1);
SEGMENT.blur(SEGMENT.custom2 >> (3 + SEGMENT.check1), SEGMENT.check1);

return FRAMETIME;
} // mode_2DSindots()
Expand All @@ -5681,7 +5684,7 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g

const uint8_t kBorderWidth = 2;

SEGMENT.fadeToBlackBy(24);
SEGMENT.fadeToBlackBy(1 + SEGMENT.intensity / 5);
SEGMENT.blur(SEGMENT.custom3>>1);

// Use two out-of-sync sine waves
Expand All @@ -5698,7 +5701,7 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g

return FRAMETIME;
} // mode_2Dsquaredswirl()
static const char _data_FX_MODE_2DSQUAREDSWIRL[] PROGMEM = "Squared Swirl@,,,,Blur;;!;2";
static const char _data_FX_MODE_2DSQUAREDSWIRL[] PROGMEM = "Squared Swirl@,Fade,,,Blur;;!;2";


//////////////////////////////
Expand Down Expand Up @@ -5824,7 +5827,7 @@ uint16_t mode_2Dspaceships(void) { //// Space ships by stepko (c)05.02.21 [ht
SEGMENT.addPixelColorXY(x, y-1, color);
}
}
SEGMENT.blur(SEGMENT.intensity >> (3 - SEGMENT.check1), SEGMENT.check1);
SEGMENT.blur(SEGMENT.intensity >> 3, SEGMENT.check1);

return FRAMETIME;
}
Expand Down Expand Up @@ -5874,8 +5877,8 @@ uint16_t mode_2Dcrazybees(void) {

if (strip.now > SEGENV.step) {
SEGENV.step = strip.now + (FRAMETIME * 16 / ((SEGMENT.speed>>4)+1));
SEGMENT.fadeToBlackBy(32 + ((SEGMENT.check1*SEGMENT.intensity) >> 2));
SEGMENT.blur(SEGMENT.intensity >> 1, SEGMENT.check1);
SEGMENT.fadeToBlackBy(32 + ((SEGMENT.check1*SEGMENT.intensity) / 25));
SEGMENT.blur(SEGMENT.intensity >> (1 + SEGMENT.check1 * 2), SEGMENT.check1);
for (size_t i = 0; i < n; i++) {
uint32_t flowerCcolor = SEGMENT.color_from_palette(bee[i].hue, false, true, 255);
SEGMENT.addPixelColorXY(bee[i].aimX + 1, bee[i].aimY, flowerCcolor);
Expand Down Expand Up @@ -6220,7 +6223,7 @@ uint16_t mode_2Ddriftrose(void) {
if(SEGMENT.palette == 0) SEGMENT.wu_pixel(x, y, CHSV(i * 10, 255, 255));
else SEGMENT.wu_pixel(x, y, ColorFromPalette(SEGPALETTE, i * 10));
}
SEGMENT.blur(SEGMENT.intensity >> (4 - SEGMENT.check1), SEGMENT.check1);
SEGMENT.blur(SEGMENT.intensity >> 4, SEGMENT.check1);

return FRAMETIME;
}
Expand Down
2 changes: 1 addition & 1 deletion wled00/FX_2Dfcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void Segment::blur2D(uint8_t blur_amount, bool smear) {
const unsigned rows = virtualHeight();

const uint8_t keep = smear ? 255 : 255 - blur_amount;
const uint8_t seep = blur_amount >> (1 + smear);
const uint8_t seep = blur_amount >> 1;
uint32_t lastnew;
uint32_t last;
for (unsigned row = 0; row < rows; row++) {
Expand Down
2 changes: 1 addition & 1 deletion wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ void Segment::blur(uint8_t blur_amount, bool smear) {
}
#endif
uint8_t keep = smear ? 255 : 255 - blur_amount;
uint8_t seep = blur_amount >> (1 + smear);
uint8_t seep = blur_amount >> 1;
unsigned vlength = virtualLength();
uint32_t carryover = BLACK;
uint32_t lastnew;
Expand Down

0 comments on commit cf4d1b6

Please sign in to comment.