-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lerpColor in HSL or HSB mode now can loop the color wheel if needed #6708
Conversation
… wheel (so wrap around from hue=360 to hue=0 if needed)
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page! |
Thanks for implementing this @Bumblebee00! I think this implementation makes sense. Just a heads up, some tests are currently failing. Could you take a look and double check that these are all because the old value being checked for was lerping the wrong way, and update the tests if so? Here's the output from the test runner: Test output
I'm going to tag the color stewards to double-check, are any of you able to also take a look? @paulaxisabel, @SoundaryaKoutharapu, @mrbrack, @TJ723, @Zarkv, @SkylerW99, @ramya202000, @hannahvy, @robin-haxx, @hiddenenigma Technically this would change the behaviour of existing sketches. It feels like the previous behaviour would be considered unexpected or a bug, so updating the behaviour makes sense to me, but it'd be great to get your feedback on this make sure we don't need to keep around the old behaviour too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the tests! I think this looks good to me, so I'm going to merge this one in.
@all-contributors please add @Bumblebee00 for code |
@Bumblebee00 already contributed before to code |
Resolves #6436
Changes:
I modified p5.prototype.lerpColor in src/color/creating_reading.js. Now if the color mode is HSL or HSB the interpolation of the HUE value will proceed along the shortest path on the color wheel. So for example from hue 359 to hue 1 it will increase up to 360 then wrap at 0 and increase up to 1. I tried implementing this as suggested in the issue discussion (converting the color to vector and the using slerp), but I found another simpler solution that works.
Screenshots of the change:
Lerping from 340 to 20 before:
Lerping from 340 to 20 now:
PR Checklist
npm run lint
passes