Skip to content

fix: lerp colors in current color mode#8920

Open
pupuking723 wants to merge 1 commit into
processing:mainfrom
pupuking723:fix/lerpcolor-current-mode
Open

fix: lerp colors in current color mode#8920
pupuking723 wants to merge 1 commit into
processing:mainfrom
pupuking723:fix/lerpcolor-current-mode

Conversation

@pupuking723

Copy link
Copy Markdown

Resolves #8883

Changes:

  • Makes Color.lerp() interpolate in the explicit mode passed by lerpColor(), instead of interpolating in the source colors' original color space and only formatting the result in the current mode.
  • Keeps the existing fallback behavior when no mode is passed.
  • Updates the existing HSL/HSB lerpColor() expectations to match current-mode interpolation. I did not add a new regression test, following the maintainer request in [p5.js 2.0+ Bug Report]: lerpColor() not affected by colorMode() #8883 to start with just the fix.

Screenshots of the change:
Not applicable.

PR Checklist

  • npm run lint passes
  • [Inline reference] is included / updated
  • [Unit tests] are included / updated

Verification:

  • npm test -- --run test/unit/color/creating_reading.js test/unit/color/p5.Color.js
  • npm run lint

AI assistance disclosure: I used Codex assistively while preparing this change. I reviewed the issue discussion, source changes, test updates, and verification output myself, and I take responsibility for the PR.

@p5-bot

p5-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

Continuous Release

CDN link

Published Packages

Commit hash: 10cf56d

Previous deployments

This is an automated message.

@pupuking723

Copy link
Copy Markdown
Author

Thanks for taking a look at this.

I checked the current failing CI job. The only failing test I found is in test/unit/webgl/p5.Framebuffer.js for saveCanvas, where the assertion expected document.createElement("a") but the recorded calls were canvas. That appears unrelated to the lerpColor() / color-mode change in this PR.

For the color-related change, I verified the affected tests locally:

  • npm test -- --run test/unit/color/creating_reading.js test/unit/color/p5.Color.js
  • npx eslint src/color/p5.Color.js test/unit/color/creating_reading.js

One clarification on the test diff: I did not add a new regression test, but the existing HSL/HSB lerpColor() expectations encoded the old RGB interpolation behavior. After making the interpolation use the current color mode, those existing expectations needed to be updated to match the corrected behavior.

If you would prefer a source-only PR first, I can adjust the test changes based on your preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[p5.js 2.0+ Bug Report]: lerpColor() not affected by colorMode()

1 participant