859 {
860 if (blendType == LINEARBLEND_NOWRAP) {
861 index =
map8(index, 0, 247);
862
863 }
864
865 uint8_t hi5 = index;
866#if defined(__AVR__)
867 hi5 /= 2;
868 hi5 /= 2;
869 hi5 /= 2;
870#else
871 hi5 >>= 3;
872#endif
873 uint8_t lo3 = index & 0x07;
874
875 uint8_t hi5XsizeofCHSV = hi5 *
sizeof(
CHSV);
876 const CHSV *entry = (
CHSV *)((uint8_t *)(&(pal[0])) + hi5XsizeofCHSV);
877
878 uint8_t hue1 = entry->hue;
879 uint8_t sat1 = entry->sat;
880 uint8_t val1 = entry->val;
881
882 uint8_t
blend = lo3 && (blendType != NOBLEND);
883
885
886 if (hi5 == 31) {
887 entry = &(pal[0]);
888 } else {
889 ++entry;
890 }
891
892 uint8_t f2 = lo3 << 5;
893 uint8_t f1 = 255 - f2;
894
895 uint8_t hue2 = entry->hue;
896 uint8_t sat2 = entry->sat;
897 uint8_t val2 = entry->val;
898
899
900
901
902
903
904
905
906
907
908
909
910 if (sat1 == 0 || val1 == 0) {
911 hue1 = hue2;
912 }
913
914
915
916 if (sat2 == 0 || val2 == 0) {
917 hue2 = hue1;
918 }
919
922
925
926
927
928
929 sat1 += sat2;
930 val1 += val2;
931
932 uint8_t deltaHue = (uint8_t)(hue2 - hue1);
933 if (deltaHue & 0x80) {
934
935 hue1 -=
scale8(256 - deltaHue, f2);
936 } else {
937
938 hue1 +=
scale8(deltaHue, f2);
939 }
940
942 }
943
946 }
947
948 return CHSV(hue1, sat1, val1);
949}
UISlider brightness("Brightness", 255, 0, 255, 1)
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
LIB8STATIC uint8_t map8(uint8_t in, uint8_t rangeStart, uint8_t rangeEnd)
Map from one full-range 8-bit value into a narrower range of 8-bit values, possibly a range of hues.
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8() does not clean up the R1 register on AVR.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video(uint8_t i, fract8 scale)
The "video" version of scale8() guarantees that the output will be only be zero if one or both of the...
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
Representation of an HSV pixel (hue, saturation, value (aka brightness)).