fix: use sRGB for color picker XY conversions, add XY sliders for color_xy devices#461
Open
Mihonarium wants to merge 3 commits intoNerivec:mainfrom
Open
fix: use sRGB for color picker XY conversions, add XY sliders for color_xy devices#461Mihonarium wants to merge 3 commits intoNerivec:mainfrom
Mihonarium wants to merge 3 commits intoNerivec:mainfrom
Conversation
- Added SRGB gamut definition (sRGB primaries + gamma) and exported it. - `convertToColor` now uses sRGB for all RGB/HSV/hex ↔ XY conversions instead of the device gamut
When format === "color_xy": shows X and Y sliders (range 0–0.74 and 0–0.84 respectively, step 0.001) with gradient backgrounds that sample actual CIE colors along each axis When format === "color_hs": shows the original hue/saturation sliders as before Both still show the hex/rgb/hsv/xyY text inputs below
Add XY color input handling to ColorEditor
Author
Owner
|
As mentioned in the linked issue, we need to fix the ZHC CIE handling first. Also, I don't trust anything done by AI on this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #367.
(thanks claude!)
Problem
The color editor converts RGB/HSV values to CIE XY using the device gamut (e.g. Philips Hue) instead of sRGB. Since the user's screen displays sRGB, the color they pick doesn't match the XY coordinates sent to the device. E.g., selecting a saturated cyan (#00FFCC) on a Philips Hue device produces XY ≈ (0.343, 0.387), which is near white, instead of the correct XY ≈ (0.243, 0.396).
Why sRGB, not the device gamut
RGB/HSV/hex values are always sRGB; that's what web displays render. Converting these to CIE XY must use sRGB primaries so that what the user sees on screen corresponds to what the device produces. The device firmware handles mapping CIE XY to its own physical gamut internally. Using the device gamut for this conversion effectively treats sRGB colors as if they were in the device's color space, producing wrong coordinates.
This is also the reason Koenkk/zigbee-herdsman-converters#11263 produces incorrect results for non-CIE1931 gamuts — it uses the device gamut for the RGB→XY conversion in the backend converters.
Changes
src/components/editors/index.ts:SRGBgamut definition (standard web display primaries, D65 white, sRGB gamma)convertToColornow uses sRGB for all RGB/HSV/hex ↔ XY conversionssrc/components/editors/ColorEditor.tsx:color_xyformat: show X and Y sliders (0–0.74 and 0–0.84) with live gradient backgrounds, instead of hue/saturation sliderscolor_hsformat: existing hue/saturation sliders unchanged