[Feature] Allow optional seeding from getColor#9
Merged
tristen merged 5 commits intopublisher-productionfrom Sep 3, 2025
Merged
[Feature] Allow optional seeding from getColor#9tristen merged 5 commits intopublisher-productionfrom
tristen merged 5 commits intopublisher-productionfrom
Conversation
tristen
commented
Sep 3, 2025
tristen
commented
Sep 3, 2025
Comment on lines
+76
to
+82
| _mapIndexToHue(index) { | ||
| // A hybrid approach to color distance checking in _getSequentialColor but | ||
| // for `_getDeterministicColor`. Attempts to “spread” hash values evenly to | ||
| // reduce the same hues appearing next to one another. | ||
| const golden = 0.61803398875; | ||
| return Math.round(((index * golden) % 1) * this.HUE_MAX); | ||
| } |
Member
Author
There was a problem hiding this comment.
AI proposed this idea as a cheap way to spread hues more distributed across the palette as fetching a deterministic value and comparing it using color difference would require knowing the whole list of values ahead of time.
Contributor
There was a problem hiding this comment.
That's actually not a bad approach, and picked an irrational number too, so it never repeats, which is cool. I'd maybe use a constant like Math.E though, so that we don't have magic numbers in the code that have low precision or need an explanation
AlexanderBelokon
approved these changes
Sep 3, 2025
Contributor
AlexanderBelokon
left a comment
There was a problem hiding this comment.
This looks great to me, both the API change, and the implementation 👍 Very elegant ✨
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.
Looks like this: