You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CHSV compare (== and !=) converts to CRGB before comparision #691
@marmilicious Haha, that's why I wasn't sure if it was intended behavior to convert to RGB when comparing because technically it is true. I actually discovered this with values that map to not-black (CHSV(32, 120, 221) and CHSV(33, 119, 220)), but I picked an obvious and reproducible case.
Out of curiosity, I wrote some really quick and dirty code to see how many collisions there are for a selected CHSV. I found that the closer to black a color is, the more likely there will be other CHSVs that equal it. Check this out:
//finds and prints all cases where the selected CHSV == another CHSV
#include<FastLED.h>constCHSV color1 = CHSV(42, 24, 31); //pick a CHSV to checkunsignedlong totalSoFar = 0;
voidsetup()
{
Serial.begin(1000000);
for (int h2 = 0; h2 <= 255; h2++) {
for (int s2 = 0; s2 <= 255; s2++) {
for (int v2 = 0; v2 <= 255; v2++) {
//check for HSV == HSVif (color1.h != h2 && color1.s != s2 && color1.v != v2) {
//check if there is an equality between HSV1 and HSV2 due to RGB conversionCHSV color2 = CHSV(h2, s2, v2);
if (color1 == color2) {
totalSoFar++;
Serial.print("CHSV(");
Serial.print(color1.h);
Serial.print(",");
Serial.print(color1.s);
Serial.print(",");
Serial.print(color1.v);
Serial.print(") == CHSV(");
Serial.print(h2);
Serial.print(",");
Serial.print(s2);
Serial.print(",");
Serial.print(v2);
Serial.print(") Total so far:");
Serial.println(totalSoFar);
}
}
}
}
}
Serial.print("Done!");
}
voidloop(){}
Activity
kriegsman commentedon Dec 7, 2018
Thanks for spotting that -- definitely just an oversight and we should definitely add it.
marmilicious commentedon Dec 7, 2018
But CHSV(0,0,0) and CHSV(128,0,0) would both display black, so in a way it is true, right? I guess that's sort of an edge case though.
jeremyste commentedon Dec 9, 2018
@marmilicious Haha, that's why I wasn't sure if it was intended behavior to convert to RGB when comparing because technically it is true. I actually discovered this with values that map to not-black (
CHSV(32, 120, 221)andCHSV(33, 119, 220)), but I picked an obvious and reproducible case.Out of curiosity, I wrote some really quick and dirty code to see how many collisions there are for a selected CHSV. I found that the closer to black a color is, the more likely there will be other CHSVs that equal it. Check this out:
marmilicious commentedon Dec 9, 2018
@jeremyste Nice check!
fix(hsv): compare CHSV by field instead of by its RGB rendering (#691) (