diff --git a/src/internal/NeoEase.h b/src/internal/NeoEase.h index b7b5df96..0de4d42f 100644 --- a/src/internal/NeoEase.h +++ b/src/internal/NeoEase.h @@ -307,6 +307,14 @@ class NeoEase static float Gamma(float unitValue) { - return pow(unitValue, 1.0f / 0.45f); + unitValue = unitValue * 100.0f; + if(unitValue <= 8) + { + return unitValue / 903.3f; + } + else + { + return pow((unitValue + 16.0f) / 116.0f, 3.0f); + } } }; \ No newline at end of file diff --git a/src/internal/NeoGamma.cpp b/src/internal/NeoGamma.cpp index f33cbfbd..b328016e 100644 --- a/src/internal/NeoGamma.cpp +++ b/src/internal/NeoGamma.cpp @@ -1,5 +1,6 @@ /*------------------------------------------------------------------------- NeoPixelGamma class is used to correct RGB colors for human eye gamma levels +according to CIE L*a*b lightness definition Written by Michael C. Miller. @@ -31,20 +32,20 @@ License along with NeoPixel. If not, see #include "NeoGamma.h" const uint8_t NeoGammaTableMethod::_table[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, - 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, - 12, 12, 13, 13, 14, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, - 19, 20, 20, 21, 22, 22, 23, 23, 24, 25, 25, 26, 26, 27, 28, 28, - 29, 30, 30, 31, 32, 33, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, - 41, 42, 43, 43, 44, 45, 46, 47, 48, 49, 50, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 71, - 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86, 87, 88, 89, - 91, 92, 93, 94, 96, 97, 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, - 112, 113, 115, 116, 118, 119, 121, 122, 123, 125, 126, 128, 130, 131, 133, 134, - 136, 137, 139, 140, 142, 144, 145, 147, 149, 150, 152, 154, 155, 157, 159, 160, - 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 187, 189, - 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, - 223, 225, 227, 229, 231, 233, 235, 238, 240, 242, 244, 246, 248, 251, 253, 255 + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, + 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, + 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, + 11, 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 15, 16, 16, 17, 17, + 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, + 25, 26, 26, 27, 28, 28, 29, 29, 30, 31, 31, 32, 32, 33, 34, 34, + 35, 36, 37, 37, 38, 39, 39, 40, 41, 42, 43, 43, 44, 45, 46, 47, + 47, 48, 49, 50, 51, 52, 53, 54, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 79, + 80, 81, 82, 83, 85, 86, 87, 88, 90, 91, 92, 94, 95, 96, 98, 99, + 100, 102, 103, 105, 106, 108, 109, 110, 112, 113, 115, 116, 118, 120, 121, 123, + 124, 126, 128, 129, 131, 132, 134, 136, 138, 139, 141, 143, 145, 146, 148, 150, + 152, 154, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, + 183, 185, 187, 189, 191, 193, 196, 198, 200, 202, 204, 207, 209, 211, 214, 216, + 218, 220, 223, 225, 228, 230, 232, 235, 237, 240, 242, 245, 247, 250, 252, 255 }; \ No newline at end of file diff --git a/src/internal/NeoGamma.h b/src/internal/NeoGamma.h index 9b94e241..ec3cb063 100644 --- a/src/internal/NeoGamma.h +++ b/src/internal/NeoGamma.h @@ -1,5 +1,6 @@ /*------------------------------------------------------------------------- NeoPixelGamma class is used to correct RGB colors for human eye gamma levels +according to CIE L*a*b lightness definition Written by Michael C. Miller.