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

Colors rendered in the window differ from the expected colors #148

Open
brendanzab opened this issue Aug 27, 2023 · 3 comments
Open

Colors rendered in the window differ from the expected colors #148

brendanzab opened this issue Aug 27, 2023 · 3 comments
Assignees
Labels
bug Something isn't working top-priority

Comments

@brendanzab
Copy link

brendanzab commented Aug 27, 2023

I’ve noticed some discrepancies between colors in Processing and sketches I’ve ported over to ocaml-canvas:

Processing:
Screenshot 2023-08-27 at 5 30 14 pm

ocaml-canvas:
Screenshot 2023-08-27 at 5 30 35 pm

Here, the sky color was meant to be Color.of_rgb 255 240 225, but in the ocaml-canvas version I get 254 243 232 when inspecting the window with the Digital Color Meter app on macOS. In the Processing version it is the same as I expected. I’m wondering if this is a color space issue? I hear that SRGB vs. Linear can sometimes cause problems.

@brendanzab
Copy link
Author

brendanzab commented Aug 28, 2023

AHAH! I think this might be the culprit:

CGColorSpaceRef cs = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);

kCGColorSpaceGenericRGB seems like a deprecated version of kCGColorSpaceSRGB (which explains why searching for sRGB in the repo came up with nothing). I’m not sure what color space Processing is using. Perhaps it’s doing something equivalent to initialising the color space with CGColorSpaceCreateDeviceRGB?

@brendanzab
Copy link
Author

Wondering if it would be helpful to be able to set the color space? Also, is the color space consistent between the different back ends? Not sure what the best practices for this kind of thing is.

@ddeclerck
Copy link
Collaborator

Hi,
Thanks for your investigation.
To be honest I never actually dug into color space management. It is quite possible that the different backends are currently not consistent.
We aim to remain compatible with HTML5 Canvases, which seem to use sRGB (some recent browsers seem to allow specifying a different color space).
I'll have a look at this when I find a moment.

@ddeclerck ddeclerck self-assigned this Aug 28, 2023
@ddeclerck ddeclerck added bug Something isn't working top-priority labels Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working top-priority
Projects
None yet
Development

No branches or pull requests

2 participants