Skip to content

Commit 09dad1d

Browse files
committed
GoL - Added blur slider
Blurs dead cells instead of immediately turning off depending on slider value. Blur is disabled when using overlay.
1 parent eb3406e commit 09dad1d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

wled00/FX.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5180,7 +5180,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
51805180

51815181
uint16_t &generation = SEGENV.aux0; //rename aux0 and aux1 for readability (not needed)
51825182
uint16_t &pauseFrames = SEGENV.aux1;
5183-
CRGB backgroundColor = SEGCOLOR(1);
5183+
CRGB bgColor = SEGCOLOR(1);
51845184
CRGB color;
51855185

51865186
if (SEGENV.call == 0) {
@@ -5200,7 +5200,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
52005200
setBitValue(cells, y * cols + x, false);
52015201
setBitValue(futureCells, y * cols + x, false);
52025202
if (SEGMENT.check2) continue;
5203-
SEGMENT.setPixelColorXY(x,y, !SEGMENT.check1?backgroundColor : RGBW32(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0));
5203+
SEGMENT.setPixelColorXY(x,y, !SEGMENT.check1?bgColor : RGBW32(bgColor.r, bgColor.g, bgColor.b, 0));
52045204
}
52055205
else {
52065206
setBitValue(cells, y * cols + x, true);
@@ -5265,8 +5265,9 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
52655265
// count neighbors and store upto 3 neighbor colors
52665266
if (getBitValue(cells, cIndex)) { //if alive
52675267
neighbors++;
5268+
if (!getBitValue(futureCells, cIndex)) continue; //parent just died, color lost
52685269
color = SEGMENT.getPixelColorXY(cX, cY);
5269-
if (color == backgroundColor) continue; //parent just died, color lost
5270+
if (color == bgColor) continue;
52705271
nColors[colorCount%3] = color;
52715272
colorCount++;
52725273
}
@@ -5278,7 +5279,8 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
52785279
// Loneliness or overpopulation
52795280
cellChanged = true;
52805281
setBitValue(futureCells, y * cols + x, false);
5281-
if (!SEGMENT.check2) SEGMENT.setPixelColorXY(x,y, !SEGMENT.check1?backgroundColor : RGBW32(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0));
5282+
// blur/turn off dying cells
5283+
if (!SEGMENT.check2) SEGMENT.setPixelColorXY(x,y, blend(SEGMENT.getPixelColorXY(x,y), bgColor, map(SEGMENT.custom1, 0, 255, 255, 0)));
52825284
}
52835285
else if (!(cellValue) && (neighbors == 3)) {
52845286
// Reproduction
@@ -5296,11 +5298,13 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
52965298
else if (colorCount == 1) dominantColor = nColors[0]; // 2 leading parents died
52975299
else dominantColor = color; // all parents died last used color
52985300
// mutate color chance
5299-
if (random8() < SEGMENT.intensity) dominantColor = !SEGMENT.check1?SEGMENT.color_from_palette(random8(), false, PALETTE_SOLID_WRAP, 0): random16()*random16();
5300-
5301+
if (random8() < SEGMENT.intensity || dominantColor == bgColor) dominantColor = !SEGMENT.check1?SEGMENT.color_from_palette(random8(), false, PALETTE_SOLID_WRAP, 0): random16()*random16();
53015302
if (SEGMENT.check1) dominantColor = RGBW32(dominantColor.r, dominantColor.g, dominantColor.b, 0); //WLEDMM support all colors
53025303
SEGMENT.setPixelColorXY(x,y, dominantColor);
5303-
}
5304+
}
5305+
else { // blur dead cells
5306+
if (!cellValue && !SEGMENT.check2) SEGMENT.setPixelColorXY(x,y, blend(SEGMENT.getPixelColorXY(x,y), bgColor, map(SEGMENT.custom1, 0, 255, 255, 0)));
5307+
}
53045308
}
53055309
//update cell values
53065310
memcpy(cells, futureCells, dataSize);
@@ -5323,7 +5327,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
53235327
SEGENV.step = strip.now;
53245328
return FRAMETIME;
53255329
} // mode_2Dgameoflife()
5326-
static const char _data_FX_MODE_2DGAMEOFLIFE[] PROGMEM = "Game Of Life@!,Color Mutation ☾,,,,All Colors ☾,Overlay ☾,Wrap ☾,;!,!;!;2;sx=200,ix=12,c1=0,o3=1";
5330+
static const char _data_FX_MODE_2DGAMEOFLIFE[] PROGMEM = "Game Of Life@!,Color Mutation ☾,Blur ☾,,,All Colors ☾,Overlay ☾,Wrap ☾,;!,!;!;2;sx=200,ix=12,c1=0,o3=1";
53275331

53285332
/////////////////////////
53295333
// 2D Hiphotic //

0 commit comments

Comments
 (0)