CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

🐞 Interpreted theme colors are inaccurate

Open austincondiff opened this issue 2 years ago • 8 comments

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 avatar Oct 27 '23 04:10 austincondiff

@austincondiff I'm looking into this, do you have a concrete example where this problem is obvious ?

armartinez avatar Jan 15 '24 14:01 armartinez

@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.

image

I sampled colors from the following sources and this is what I got...

image

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 avatar Jan 15 '24 15:01 austincondiff

@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.

armartinez avatar Jan 15 '24 15:01 armartinez

@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) :

Screenshot 2024-01-16 at 13 10 15

armartinez avatar Jan 16 '24 12:01 armartinez

@armartinez could you clarify what you mean exactly by...

  1. 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?
  2. 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 avatar Jan 16 '24 16:01 austincondiff

@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.

armartinez avatar Jan 16 '24 16:01 armartinez

Sounds good to me!

austincondiff avatar Jan 16 '24 16:01 austincondiff

@austincondiff https://github.com/CodeEditApp/CodeEdit/pull/1566

armartinez avatar Jan 17 '24 10:01 armartinez