-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fireworks only explode in a single color #5492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6824d7c
fa58999
eeab89c
4f6bdb3
85924f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3763,7 +3763,7 @@ void mode_exploding_fireworks(void) | |
| if (SEGENV.aux0 == 0) { //init flare | ||
| flare->pos = 0; | ||
| flare->posX = SEGMENT.is2D() ? hw_random16(2,cols-3) : (SEGMENT.intensity > hw_random8()); // will enable random firing side on 1D | ||
| unsigned peakHeight = 75 + hw_random8(180); //0-255 | ||
| unsigned peakHeight = 84 + hw_random8(146); // 33% to 90% of 256 | ||
| peakHeight = (peakHeight * (rows -1)) >> 8; | ||
| flare->vel = sqrtf(-2.0f * gravity * peakHeight); | ||
| flare->velX = SEGMENT.is2D() ? (hw_random8(9)-4)/64.0f : 0; // no X velocity on 1D | ||
|
|
@@ -3800,6 +3800,7 @@ void mode_exploding_fireworks(void) | |
|
|
||
| // initialize sparks | ||
| if (SEGENV.aux0 == 2) { | ||
| int colIndex = hw_random8(); // single color: one index shared by all sparks | ||
| for (unsigned i = 1; i < nSparks; i++) { | ||
| sparks[i].pos = flare->pos; | ||
| sparks[i].posX = flare->posX; | ||
|
|
@@ -3808,7 +3809,7 @@ void mode_exploding_fireworks(void) | |
| sparks[i].velX = SEGMENT.is2D() ? (float(hw_random16(20001)) / 10000.0f) - 1.0f : 0; // from -1 to 1 | ||
| sparks[i].col = 345;//abs(sparks[i].vel * 750.0); // set colors before scaling velocity to keep them bright | ||
| //sparks[i].col = constrain(sparks[i].col, 0, 345); | ||
| sparks[i].colIndex = hw_random8(); | ||
| sparks[i].colIndex = SEGMENT.check1 ? colIndex : hw_random8(); // single color: share one index; otherwise random per spark | ||
| sparks[i].vel *= flare->pos/rows; // proportional to height | ||
| sparks[i].velX *= SEGMENT.is2D() ? flare->posX/cols : 0; // proportional to width | ||
| sparks[i].vel *= -gravity *50; | ||
|
|
@@ -3835,9 +3836,11 @@ void mode_exploding_fireworks(void) | |
| c = color_blend(spColor, WHITE, uint8_t((prog - 300)*5)); | ||
| } else if (prog > 45) { //fade from spark color to black | ||
| c = color_blend(BLACK, spColor, uint8_t(prog - 45)); | ||
| unsigned cooling = (300 - prog) >> 5; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai is removing this block a user-visible change, or just refactoring?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🧠 Learnings used |
||
| c.g = qsub8(c.g, cooling); | ||
| c.b = qsub8(c.b, cooling * 2); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code comes from the original algorithm code. In that code the firework always explodes as white, then fades to yellow, before fading to black. Where the firework here can be any color. If it is already yellow it doesn't fade at all. If it is blue or green it fades completely before the fade to black even starts. |
||
| if (!SEGMENT.check1) { // without single color, shift toward red/orange as sparks cool | ||
| unsigned cooling = (300 - prog) >> 5; | ||
| c.g = qsub8(c.g, cooling); | ||
| c.b = qsub8(c.b, cooling * 2); | ||
| } | ||
| } | ||
| if (SEGMENT.is2D()) SEGMENT.setPixelColorXY(int(sparks[i].posX), rows - int(sparks[i].pos) - 1, c); | ||
| else SEGMENT.setPixelColor(int(sparks[i].posX) ? rows - int(sparks[i].pos) - 1 : int(sparks[i].pos), c); | ||
|
|
@@ -3856,7 +3859,7 @@ void mode_exploding_fireworks(void) | |
| } | ||
| } | ||
| #undef MAX_SPARKS | ||
| static const char _data_FX_MODE_EXPLODING_FIREWORKS[] PROGMEM = "Fireworks 1D@Gravity,Firing side;!,!;!;12;pal=11,ix=128"; | ||
| static const char _data_FX_MODE_EXPLODING_FIREWORKS[] PROGMEM = "Fireworks 1D@Gravity,Firing side,,,,Single Color;!,!;!;12;pal=11,ix=128"; | ||
| #endif // WLED_PS_DONT_REPLACE_x_FX | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2812,7 +2812,7 @@ function loadPalettesData() { | |
| if (lsPalData) { | ||
| try { | ||
| var d = JSON.parse(lsPalData); | ||
| if (d && d.vid == lastinfo.vid) { | ||
| if (d && d.vid == lastinfo.vid && d.pcount == lJson.length) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RussStringham what is the purpose of this change? is it a bugfix?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new Fireworks palette didn't display the palette at the bottom of the selector, because the cache wasn't regenerated since the vid didn't change. This forced a cache update for the new palette.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is actually a fix for a long standing bug.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this fix is actually incomplete. I will add the correct version in a seperate PR |
||
| palettesData = d.p; | ||
| redrawPalPrev(); | ||
| return resolve(); | ||
|
|
@@ -2824,7 +2824,8 @@ function loadPalettesData() { | |
| getPalettesData(0, () => { | ||
| localStorage.setItem("wledPalx", JSON.stringify({ | ||
| p: palettesData, | ||
| vid: lastinfo.vid | ||
| vid: lastinfo.vid, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RussStringham please explain
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the comment for line 2815 |
||
| pcount: lJson.length | ||
| })); | ||
| redrawPalPrev(); | ||
| setTimeout(resolve, 99); // delay optional | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the firework goes to the very top, it only explodes down, rather than in both directions. If it is too low, it mostly explodes up.