Skip to content
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

Fix PaletteStudio color sorting #213

Merged
merged 2 commits into from
Dec 18, 2021
Merged

Conversation

hamoid
Copy link
Member

@hamoid hamoid commented Dec 14, 2021

getLuminance() returns a normalized Double.

The comparator used the difference of two normalized luminances and converted the result .toInt() which gave 0 in most cases, which did not sort the colors as expected.

Copy link
Member

@edwinRNDR edwinRNDR left a comment

Choose a reason for hiding this comment

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

There is a really nice idiomatic way to do this in Kotlin: colors.sortedBy { getLuminance(it) } and colors.sortedByDescending { getLuminance(it) }

@hamoid
Copy link
Member Author

hamoid commented Dec 18, 2021

Yeah much nicer :)

@edwinRNDR edwinRNDR merged commit 26f4aa5 into openrndr:master Dec 18, 2021
@hamoid hamoid deleted the fixPaletteSorting branch December 18, 2021 18:58
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.

2 participants