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

Fix color higher than 255 #1

Closed
wants to merge 16 commits into from
Closed

Fix color higher than 255 #1

wants to merge 16 commits into from

Conversation

mixman68
Copy link
Owner

@mixman68 mixman68 commented Dec 3, 2017

I had tried to fix colors, more info at : sqmk#114

require_once __DIR__ . '/vendor/autoload.php';

use \Phue\Helper\ColorConversion;

function testConvert($r,$g,$b) {
  $xy = ColorConversion::convertRGBToXY($r,$g,$b);
  
  $rgbConverted = ColorConversion::convertXYToRGB($xy["x"],$xy["y"],$xy["bri"]);
  echo "$r $g $b => {$rgbConverted['red']} {$rgbConverted['green']} {$rgbConverted['blue']}", PHP_EOL;
}

testConvert(255,0,0);
testConvert(200,50,0);
testConvert(200,50,0);
testConvert(243,50,6);
testConvert(200,143,68);
testConvert(233,230,211);
testConvert(33,232,11);
testConvert(2,32,113);
testConvert(98,23,234);

The conversion to XY is correct, same as other library excepted ignorance of Gamut of bulb
So i try to convert to XY and back to RGB
and i have these results :

255 0 0 => 254 0 0
200 50 0 => 200 50 0
200 50 0 => 200 50 0
243 50 6 => 242 50 6
200 143 68 => 200 143 68
233 230 211 => 233 230 211
33 232 11 => 33 232 11
2 32 113 => 2 34 119
98 23 234 => 97 23 232

@mixman68 mixman68 closed this Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants