[tbb-dev] Canvas Breakage Ideas

David Fifield david at bamsoftware.com
Tue Jun 30 18:45:33 UTC 2020

On Tue, Jun 30, 2020 at 12:42:57PM -0600, David Fifield wrote:
> I was wondering whether color management affects canvas rendering. Like,
> does `rgb(100, 120, 140)` always represent the same sRGB-encoded value
> when written to a PNG, or could it depend on monitor and OS color
> management settings?
> What about the new wide-gamut colors available in CSS? Can those be used
> in canvas? What happens when they are written to a PNG? If the writing
> process maps them back into sRGB space, is that process deterministic?
> https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/
> https://graphicdon.com/2020/05/27/the-expanding-gamut-of-color-on-the-web/

Sorry, just found one more relevant link.

	# Wide-gamut colors in HTML

	While CSS handles most of the presentation of an HTML document,
	there is still one important area which is outside its scope:
	the `canvas` element. Both 2D and WebGL canvases assume they
	operate within the sRGB color space. This means that even on
	wide-gamut displays, you won’t be able to create a canvas that
	exercises the full range of color.

	The proposed solution is to add an optional flag to the
	`getContext` function, specifying the color space the canvas
	should be color matched to. For example:

	// NOTE: Proposed syntax. Not yet implemented.
	canvas.getContext("2d", { colorSpace: "p3" });

More information about the tbb-dev mailing list