-
Notifications
You must be signed in to change notification settings - Fork 61
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 and Substract - clamp after operations? #19
Comments
That may mess with the math. I think it's better to clamp just before converting. Isn't that already implemented? |
Currently not implemented even in the current master.
|
Yes, it is in each conversion function. |
I've at this looked at this function link I am not sure I understand it correctly. Lets say I have 2 Rgb and I add them and convert to [u8;3]. These is no clamping in this process, is there? |
No, it happens in the functions I linked to, just before those are called. It may still be a good idea to clamp after multiplying with 255, because of how floating point math works. |
Fix or relax some color ranges and clamping The `ColorSpace` trait has been repurposed as a trait for checking limits and clamping, and is now called `Limited`. The limits of `Xyz` has been changed to use the white point as its maximum (closing #10), and the maximum of `Lch.chroma` has been removed, since it's not very well defined. The ranges of `Lch` stays as they are, for the sake of consistency. Extra clamping is also added when converting RGB colors to `u8` based pixel representation, to prevent float shenanigans when multiplying values with 255.0. It's impossible to know what a type `T` will do when it's asked to convert `255.12312312` or whatever to `u8`. This closes #19. This is a breaking change, since it changes the ranges of some color spaces and renames the `ColorSpace` trait to `Limited`.
For colors with known ranges like rgb, hsl etc., should we clamp the values? A possible issue is with the f32 -> u8 conversion panicking if not clamped.
The text was updated successfully, but these errors were encountered: