q5js / q5.js

A sequel to p5.js that's optimized for interactive art!
https://q5js.org
GNU Lesser General Public License v3.0
123 stars 9 forks source link

Add support for Float RGB #57

Closed quinton-ashley closed 3 months ago

quinton-ashley commented 4 months ago

In CSS color(srgb ...) and color(display-p3 ...) use the new float (0-1) rgb format.

I think the legacy 8-bit (0-255), integer rgb format should remain the default for the q2d renderer, but for the upcoming webgpu renderer the float rgb format should be the default, since it's also the default color format for all of webgpu's color formats, regardless of color space.

The updated colorMode(mode, colorFormat) function will take two params: a mode ('rgb', 'srgb', or 'oklch') and a colorFormat ('integer' or 'float').

colorMode('rgb', 'float');

The current integer RGBA color classes will be renamed:

ColorRGBA_8 ColorRGBA_P3_8

The float color classes will be named:

ColorRGBA ColorRGBA_P3