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

Add methods to map color components #9

Merged
merged 1 commit into from
Nov 6, 2024
Merged

Add methods to map color components #9

merged 1 commit into from
Nov 6, 2024

Conversation

raphlinus
Copy link
Contributor

These are convenience methods, but should provide a nice concise way to express common operations on colors, subsuming a lot of single-use methods.

Arguably 'map_lightness' should become a method on ColorSpace, very similar to scale_chroma, as similar math optimizations apply.

These are convenience methods, but should provide a nice concise way to express common operations on colors, subsuming a lot of single-use methods.

Arguably 'map_lightness' should become a method on `ColorSpace`, very similar to `scale_chroma`, as similar math optimizations apply.
/// Otherwise, do the mapping in Oklab. The lightness range is normalized so
/// that 1.0 is white.
#[must_use]
pub fn map_lightness(self, f: impl Fn(f32) -> f32) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Another candidate would be map_hue due to its natural representation in all polar spaces.

@raphlinus raphlinus added this pull request to the merge queue Nov 6, 2024
Merged via the queue into main with commit e824f67 Nov 6, 2024
15 checks passed
@raphlinus raphlinus deleted the map branch November 6, 2024 17:26
@waywardmonkeys waywardmonkeys mentioned this pull request Nov 8, 2024
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.

4 participants