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

Move conversion logic into ColorSpace #8

Merged
merged 3 commits into from
Nov 6, 2024
Merged

Move conversion logic into ColorSpace #8

merged 3 commits into from
Nov 6, 2024

Conversation

raphlinus
Copy link
Contributor

Add a convert method to ColorSpace, and migrate logic in the individual color types to use that.

One consequence is that gradient interpolation in Oklch is expected to be faster, as the conversion to Oklab for error evaluation now doesn't go all the way back to linear sRGB.

Also adds examples from koloro crate, which were inadvertently omitted from the initial commit.

Removes TaggedColor::from_linear_srgb method, as that functionality can now be expressed more idiomatically with properly typed colors.

Add a `convert` method to `ColorSpace`, and migrate logic in the individual color types to use that.

One consequence is that gradient interpolation in Oklch is expected to be faster, as the conversion to Oklab for error evaluation now doesn't go all the way back to linear sRGB.

Also adds examples from koloro crate, which were inadvertently omitted from the initial commit.

Removes `TaggedColor::from_linear_srgb` method, as that functionality can now be expressed more idiomatically with properly typed colors.
We had the conversions in the tagged case but not for static color types.
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

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

Looks good.

@@ -145,6 +145,15 @@ impl ColorSpaceTag {
}
}

pub fn convert(self, target: Self, src: [f32; 3]) -> [f32; 3] {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this could have a short doc comment?

@raphlinus raphlinus added this pull request to the merge queue Nov 6, 2024
Merged via the queue into main with commit 3c169ab Nov 6, 2024
15 checks passed
@raphlinus raphlinus deleted the convert branch November 6, 2024 11:01
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