Skip to content

fix createColorPicker ignores initial colour arg on chrome#8363

Merged
davepagurek merged 7 commits intoprocessing:dev-2.0from
Piyushrathoree:fix-createColorPicker-ignore-initial-color
Jan 27, 2026
Merged

fix createColorPicker ignores initial colour arg on chrome#8363
davepagurek merged 7 commits intoprocessing:dev-2.0from
Piyushrathoree:fix-createColorPicker-ignore-initial-color

Conversation

@Piyushrathoree
Copy link

Resolves #8284

Changes:

I updated toString() in p5.Color.js to handle the #rrggbb format manually. It now calculates the values directly and ensures we always return a full 6-digit hex string. This fixes the issue for initial color breaking on createColorPicker.

Screenshots of the change:

image

PR Checklist

@Piyushrathoree Piyushrathoree marked this pull request as ready for review December 27, 2025 09:27
@Piyushrathoree Piyushrathoree force-pushed the fix-createColorPicker-ignore-initial-color branch from 68c16e9 to 2271a30 Compare December 27, 2025 11:32
@Piyushrathoree
Copy link
Author

@davepagurek could you please take a look

format: outputFormat
});

if (format === '#rrggbb') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part of the code necessary? What does colorString look like after we pass hex into serialize?

Copy link
Author

@Piyushrathoree Piyushrathoree Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just checked it, seems like it is not necessary removing it right now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated @davepagurek

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just checked it, seems like it is not necessary removing it right now.

when I try to remove it multiple tests are breaking , I'm not sure but it is converting even colors like 'rgb(100% 0% 40% / 0.8)' to string which is causing the problem and that's why this check it important.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reading this more closely, is this just turning strings like #FFF into #FFFFFF? if so, could we do this without the regex and just use the indices of characters in the string since color serialization happens so frequently in p5?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I just checked this commit f465feb and it looks like that's applying the regex length thing to ALL color formats. I originally was asking if it was necessary to adjust the output of colorjs at all, e.g. removing the whole if statement including its contents.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @davepagurek ! I've updated the code to use string indices instead of regex. Now it directly accesses characters by their position (e.g., colorString[1], colorString[2]) and checks the length (=== 4 for short hex) rather than using regex pattern matching.
I 've tried and tested it working fine , please take look.

@Piyushrathoree Piyushrathoree force-pushed the fix-createColorPicker-ignore-initial-color branch from 5db49bd to f465feb Compare December 31, 2025 21:04
@Piyushrathoree Piyushrathoree force-pushed the fix-createColorPicker-ignore-initial-color branch from c6728c0 to 33b8ca3 Compare December 31, 2025 21:21
@Piyushrathoree
Copy link
Author

@davepagurek please take a look .

@davepagurek
Copy link
Contributor

Hey @Piyushrathoree! Just checking in, are you still working on this one? I left some more comments on the thread above to try to clarify some things.

@davepagurek
Copy link
Contributor

Also there were some merge conflicts -- in dev-2.0, now it returns the input string to color(...) if it is present and if the format is not being converted -- let me know if I can explain any of those updates.

@Piyushrathoree
Copy link
Author

Also there were some merge conflicts -- in dev-2.0, now it returns the input string to color(...) if it is present and if the format is not being converted -- let me know if I can explain any of those updates.

got it will resolve soon

@Piyushrathoree
Copy link
Author

Also there were some merge conflicts -- in dev-2.0, now it returns the input string to color(...) if it is present and if the format is not being converted -- let me know if I can explain any of those updates.

I pulled the changes first and then pushed the new changes; I didn't encounter any issue.

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those changes!

@davepagurek davepagurek merged commit bf773b7 into processing:dev-2.0 Jan 27, 2026
2 checks passed
@Piyushrathoree
Copy link
Author

Thanks for making those changes!

actually I was busy in my exams sorry for the delay

@Piyushrathoree
Copy link
Author

Thanks for making those changes!

actually I was busy in my exams sorry for the delay

@ksen0 ksen0 added this to the 2.3 milestone Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

3 participants