Repository navigation
Support colorMode() in p5.strands so color() can build colors from HSB/HSL values - #9443
Open
Akshats-git wants to merge 3 commits into
Open
Akshats-git wants to merge 3 commits into
Akshats-git wants to merge 3 commits into
Conversation
Calling colorMode() inside a shader now only affects that shader, not the whole sketch. Part of processing#9432.
In HSB mode it now returns HSB saturation, so it pairs with brightness(). Part of processing#9432.
Things like color(hue(c), 1, 1) now work in RGB, HSB and HSL instead of compiling to NaN. Also updates the docs. Closes processing#9432.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #9432
Changes:
As discussed with @davepagurek on Discord,
colorMode()is now part of the strands state likenoiseDetail().colorMode()inside a shader only affects that shader. It no longer changes the sketch's color mode. If it isn't called then the sketch's color mode is used.color()now works with shader values likecolor(hue(c), 1, 1). Before, these compiled toNaN. The result is always an RGBAvec4.saturation()returns HSB saturation in HSB mode, so it pairs withbrightness(). A color like#ff8080now round trips correctly.fract()instead ofmod()so WebGL and WebGPU give the same result.colorMode()has no effect in strands and added a hue-shifting example tocolor().One question: shader values use the colorMode ranges like plain numbers do. So to pass
hue()and friends back intocolor()we needcolorMode(HSB, 1)since they return 0-1. I can switch it so strands always reads shader values as 0-1 if you would prefer.AI disclosure: I used Claude to help write parts of the code and tests. I reviewed and tested all of it.
PR Checklist
npm run lintpasses