-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implement a _repr_html_
method for the Color
class
#429
Comments
It's an interesting idea. It definitely has limited use cases, but I can see it being useful in Jupyter. So Jupyter specifically uses |
I guess you'd run into the issue of what gamut do we format the colors in...you'd need some class option to output in display-p3 if your monitor supports it. I guess sRGB would be the safe default. |
I converted the color to OKLCH because, as far as I know, the browser takes care of converting it to a color that the monitor can display. Regarding |
Yeah, you could let the browser gamut map out itself. Currently most just clip though which isn't great. |
The |
Thanks for the example. Yeah, it's not a bad idea, and it doesn't hurt us to have it. Let me play around with it. |
I just found out about w3c/csswg-drafts#9449. I wasn't really aware of this issue. I think this looks good! I had forgotten about the transparency grid. Personally, I'm not a big fan of ridge borders. But that's minor |
Open to suggestions, we could do some kind of double border. I was more looking for something where the border stood out on light and dark backgrounds. |
Much better! Thanks for working on this so quickly :) |
Yeah, I'm not particularly fond of ridge either, but I also threw it together pretty quickly :).
Yeah, they are still trying to figure out how browsers will gamut map things. Basically what it boils down is CSS offers a proposal to gamut map and preserve lightness in a perceptual color space, which has many uses, but admittedly, it is not as good for image gamut mapping etc. Preserving chroma can be quite desirable with images. Some browsers want one GMA to rule them all, but supporting preserving chroma with GMA and preserving lightness with GMA are at odds with each other and have different use cases. There are also a lot of opinions on a great number of little details as well. I think Chrome is pushing hard to have some kind of baked in logic for each supported gamut while CSS has a generic (and slow) algorithm. Nobody has been super clear on what the criteria should be, so now it seems all the browsers are waiting to see what Chrome resolves with the CSS WG. Who knows what the final solution will look like. There a lot of other opinions out there too about a great number of things. |
Thanks for the explanation! |
When working with colors in a Jupyter notebook (or Quarto), it can be helpful to visualize the colors directly. While there are several ways to do this, having this functionality built into
coloraid
via a_repr_html_
method would be very convenient.Although this feature might fall outside the intended scope of the library, here’s a quick example I wrote:
This is just a quick implementation, and I’m sure there are a number of ways it could be improved.
The text was updated successfully, but these errors were encountered: