-
Notifications
You must be signed in to change notification settings - Fork 19
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
Consider more generic ways to represent and invert channels #24
Comments
Couldn't we just expand the channel for lightness to also use the full range of its integer type? |
yeah, sure. But if that should be meaningful, we’d need because neither an |
Perhaps we could have tag types for the 4 sizes of integers, with a trait + associated types specifying the signed and unsigned versions. Thus you can specialize the color models on the tag types and have signed ints for some components and unsigned ints for other components. |
sorry, i’m a rust noob: tag types? but i understand what you mean. basically something connecting both. |
Something like this struct Int8;
impl Something for Int8 {
type Signed = i8;
type Unsigned = u8;
}
struct ColorLab<T: Something> {
L: T::Unsigned,
a: T::Signed,
b: T::Signed,
}
// Code can now use ColorLab<Int8> |
ah, that brand new thing! very good idea. here is also an awesome comprehensive implementation of this calculator powered by this math. |
Thanks for spending the time to write this up! I will have to spend some digesting this. Are you available on #rust-gamedev at any time to have a chat? |
sure, i’ll hop on right now! as it’s been almost 24 hours ago that you commented, you could be there :D /edit: you weren’t there. usually i’m online from around the time this comment was originally made (19-20⁰⁰ CET) |
Lab* colors are usually represented as one of the following two
the last one more “accomodating” to computers (to almost represent them as
i8
, i guess).now adding this is a problem: we’d have to add two more ways to invert this:
100 - L
and the simple-a
/-b
.i think we should consider a way to handle this, e.g. by tying the kind of channel to the color model:
that would involve either normalizing float channels (always clamp to [-1..1] or [0..1], modulo when circular). also bits would be lost: using 3×i8 for Lab* would mean using all int values from -128 to 127, but only 100 lightness levels!
do you have a different idea how to handle this?
The text was updated successfully, but these errors were encountered: