Most appropriate sub-area of p5.js?
p5.js version
2.3.3
Web browser and version
Arc 1.164
Operating system
MacOSX 15.7.7
Steps to reproduce this
Steps:
- Create two colors
- Set the color mode the RGB and use lerpColor to interpolate between them
- Change the color mode to HSB and use lerpColor again
Snippet:
const divisions = 10;
let startColor;
let endColor;
function setup() {
createCanvas(600, 600);
startColor = color("red");
endColor = color("green");
noStroke();
}
function draw() {
background(255);
colorMode(RGB);
const sliceWidth = width / divisions;
for (let i = 0; i < divisions; i++) {
const c = lerpColor(startColor, endColor, i / divisions);
fill(c);
rect(i * sliceWidth, 10, sliceWidth, 100);
}
colorMode(HSB);
for (let i = 0; i < divisions; i++) {
const c = lerpColor(startColor, endColor, i / divisions);
fill(c);
rect(i * sliceWidth, 120, sliceWidth, 100);
}
}
I would expect two different bands as the interpolation happens in either RGB or HSB space. This was the case in v1 and is what is stated in the documentation. However, both are interpolated in RGB space.
If I switch the color creation to happen in HSB space
colorMode(HSB);
startColor = color("red");
endColor = color("green");
the bands stay the same. It appears that despite being in HSB mode, this still creates RGB colors.
If I specify them fully
colorMode(HSB, 360, 100, 100);
startColor = color(0, 100, 100);
endColor = color(100, 100, 100);
then both bands interpolate in HSB. If I only switch one of the colors, then the bands stay in RGB mode.
I see #9024 which claims to have fixed this, but I still see the problem.
Most appropriate sub-area of p5.js?
p5.js version
2.3.3
Web browser and version
Arc 1.164
Operating system
MacOSX 15.7.7
Steps to reproduce this
Steps:
Snippet:
I would expect two different bands as the interpolation happens in either RGB or HSB space. This was the case in v1 and is what is stated in the documentation. However, both are interpolated in RGB space.
If I switch the color creation to happen in HSB space
the bands stay the same. It appears that despite being in HSB mode, this still creates RGB colors.
If I specify them fully
then both bands interpolate in HSB. If I only switch one of the colors, then the bands stay in RGB mode.
I see #9024 which claims to have fixed this, but I still see the problem.