Skip to content
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

update build-CI, badges and new functions #3

Merged
merged 16 commits into from
Nov 6, 2021
Prev Previous commit
Next Next commit
fix
  • Loading branch information
RobTillaart committed Nov 6, 2021
commit 8d4881c93b5ac87ac2304b3bae480fc5674c14f5
5 changes: 4 additions & 1 deletion Kelvin2RGB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ uint16_t Kelvin2RGB::RGB565()

uint32_t Kelvin2RGB::CMYK()
{
float k = 1 - Max(Max(_red, _green), _blue);
float k = _red;
if (k < _green) k = _green;
if (k < _blue) k = _blue;
k = 1 - k;
uint8_t c = 255 * (1 - _red - k) / (1 - k);
uint8_t m = 255 * (1 - _green - k) / (1 - k);
uint8_t y = 255 * (1 - _blue - k) / (1 - k);
Expand Down
25 changes: 25 additions & 0 deletions test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,31 @@ unittest(test_Neil_Bartlett)
}


unittest(test_colour_spaces)
{
Kelvin2RGB tempColor;

fprintf(stderr, "test_colour_spaces\n");
tempColor.setRGB(0.1, 0.2, 0.3, 0.9);

fprintf(stderr, "BRIGHT: %d\n", tempColor.brightness());
fprintf(stderr, "RED : %d\n", tempColor.red());
fprintf(stderr, "GREEN : %d\n", tempColor.green());
fprintf(stderr, "BLUE : %d\n", tempColor.blue());
fprintf(stderr, "RGB : %d\n", tempColor.RGB());
fprintf(stderr, "BGR : %d\n", tempColor.BGR());
fprintf(stderr, "CMYK : %d\n", tempColor.CMYK());

assertEqualFloat(100, tempColor.brightness(), 0.0001);
assertEqualFloat(1, tempColor.red(), 0.0001);
assertEqualFloat(0.707636, tempColor.green(), 0.0001);
assertEqualFloat(0.424804, tempColor.blue(), 0.0001);
assertEqual(16757868, tempColor.RGB());
assertEqual(16757868, tempColor.BGR());
assertEqual(16757868, tempColor.CMYK());
}


unittest_main()

// --------