🐞 Interpreted theme colors are inaccurate
Description
Currently in our themes we define a hex value and it ends up being a much different shade than what was specified. This may have something to do with how the hex is interpreted.
@austincondiff I'm looking into this, do you have a concrete example where this problem is obvious ?
@armartinez Yes, if you open CodeEdit/DefaultThemes/codeedit-xcode-dark.json, you will see the Xcode Dark theme. It looks like the colors are off. So we went to the theme in Xcode and sampled each color, but even them it was off.
I sampled colors from the following sources and this is what I got...
It should match the default theme in Xcode exactly. I am suspicious that when I take a screenshot, the colors are muted and I get an inaccurate sample. Maybe it doesn't capture in P3 color, or it doesn't paste into Figma (where I do the color sample) into P3 color.
@austincondiff Yeah I've been trying the Digital Color Picker but there can be differences between what is selected and what the monitor is outputting depending on the color profile. I'll try to just match the color from what it's being displayed in Xcode and CodeEdit.
@austincondiff I found the issue. Xcode uses by default the color profile Generic RGB which is an old profile from the NSColorSpace (https://developer.apple.com/documentation/appkit/nscolorspace/1412082-genericrgbcolorspace?language=objc) while SwiftUI defaults to sRGB. For us to change that we would need to refactor the whole Color extension which doesn't seem worth it. I can convert the Xcode themes to srgb easily and use those value in the CodeEdit themes, this is a sample on how that looks (Left is CodeEdit) :
@armartinez could you clarify what you mean exactly by...
- For us to change that we would need to refactor the whole Color extension
- what would be involved in doing something like this?
- why would something like this be necessary?
- I can convert the Xcode themes to srgb easily?
- Do you mean the json file in the DefaultThemes folder?
- How would you convert the theme?
- Would they still use hex values?
@austincondiff sure :
1 - We are currently using the SwiftUI Color class to represent colors. This class accepts an enum RGBColorSpace which doesn't include the Generic RGB profile. In order to use that, we would have to replace the Color class with something like CGColor which accepts a CGColorSpace argument that includes GenericRGBLinear profile or find a way to extend the Color class to accept a new type of profile, which I don't know if it's even possible.
2 - Yes I mean the json file, and I would just switch the current hex value (sRGB) for it's corresponding GenericRGB hex value.
Sounds good to me!
@austincondiff https://github.com/CodeEditApp/CodeEdit/pull/1566