[p5.js 2.0+ Bug Report]: Attempting to interpolate colors may fail with an exception if the colors are defined in different color spaces
Area:Colorp5.js 2.0+
### Most appropriate sub-area of p5.js?
- [ ] Accessibility
- [x] Color
- [ ] Core/Environment/Rendering
- [ ] Data
- [ ] DOM
- [ ] Events
- [ ] Image
- [ ] IO
- [ ] Math
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [ ] WebGPU
- [ ] p5.strands
- [ ] Build process
- [ ] Unit testing
- [ ] Internationalization
- [ ] Friendly errors
- [ ] Other (specify if possible)
### p5.js version
2.2.3
### Web browser and version
Browser-independent (tested on Safari 26.4, Chromium 148.0.7778.167)
### Operating system
macOS
### Steps to reproduce this
### Steps:
For example:
1. Define a color using `oklch`: `color("oklch(0.8, 0.1, 230)")`
2. Define another color in sRGB: `color(0)`
3. Attempt to interpolate them: `lerpColor(c_0, c_1, 0.5)`
### Result
Uncaught exception from `color.js`: `TypeError: No color space found with id = "xyz-d65"`
### Snippet:
Also see: https://editor.p5js.org/dontwanttothink/sketches/pzp5YlR8t
```js
function setup() {
createCanvas(400, 400);
}
function draw() {
const c_0 = color("oklch(0.8 0.1 230)");
const c_1 = color(0);
printColorSpacePath(c_0);
printColorSpacePath(c_1);
background(lerpColor(c_0, c_1, 0.5));
}
function printColorSpacePath(c) {
console.log(c._color.space.path.map(space => space.id))
}
```
1 条评论