Skip to content

Commit caeda96

Browse files
authored
PS bugfix: do not increase saturation of palette colors (wled#4715)
this fix prevents palette colors being saturated more if high (but not full) saturation value is set for a particle
1 parent 9805ae5 commit caeda96

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

wled00/FXparticleSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void ParticleSystem2D::render() {
594594
if (particles[i].sat < 255) {
595595
CHSV32 baseHSV;
596596
rgb2hsv((uint32_t((byte(baseRGB.r) << 16) | (byte(baseRGB.g) << 8) | (byte(baseRGB.b)))), baseHSV); // convert to HSV
597-
baseHSV.s = particles[i].sat; // set the saturation
597+
baseHSV.s = min(baseHSV.s, particles[i].sat); // set the saturation but don't increase it
598598
uint32_t tempcolor;
599599
hsv2rgb(baseHSV, tempcolor); // convert back to RGB
600600
baseRGB = (CRGB)tempcolor;
@@ -1177,7 +1177,7 @@ ParticleSystem1D::ParticleSystem1D(uint32_t length, uint32_t numberofparticles,
11771177

11781178
if (isadvanced) {
11791179
for (uint32_t i = 0; i < numParticles; i++) {
1180-
advPartProps[i].sat = 255; // set full saturation (for particles that are transferred from non-advanced system)
1180+
advPartProps[i].sat = 255; // set full saturation
11811181
}
11821182
}
11831183
}
@@ -1470,7 +1470,7 @@ void ParticleSystem1D::render() {
14701470
if (advPartProps[i].sat < 255) {
14711471
CHSV32 baseHSV;
14721472
rgb2hsv((uint32_t((byte(baseRGB.r) << 16) | (byte(baseRGB.g) << 8) | (byte(baseRGB.b)))), baseHSV); // convert to HSV
1473-
baseHSV.s = advPartProps[i].sat; // set the saturation
1473+
baseHSV.s = min(baseHSV.s, advPartProps[i].sat); // set the saturation but don't increase it
14741474
uint32_t tempcolor;
14751475
hsv2rgb(baseHSV, tempcolor); // convert back to RGB
14761476
baseRGB = (CRGB)tempcolor;

0 commit comments

Comments
 (0)