Skip to content

Conversation

@Anshumancanrock
Copy link

@Anshumancanrock Anshumancanrock commented Jan 26, 2026

Resolves #8451

Changes:

Fixes toString() not recognizing p5.js hex format strings in 2.0.

The problem is that colorjs.io doesn't recognize p5.js format strings like '#rrggbb', '#rgb', etc. So I added a simple mapping layer that translates these to colorjs.io's 'hex' format before passing them through.

Now these all work:

  • toString('#rrggbb')
  • toString('#rgb')
  • toString('#rrggbbaa')
  • toString('#rgba')
  • toString('hex') (added as alias)

Added tests for these cases too.

PR Checklist

@Anshumancanrock Anshumancanrock changed the base branch from main to dev-2.0 January 26, 2026 09:57
@Anshumancanrock Anshumancanrock changed the title Fix Color.toString() issues: add 'hex' alias and correct 'hsla%' output Fix Color.toString() hex format support Jan 26, 2026
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]: p5.Color.toString('#rrggbb') always returns HSL string

1 participant