Swap component and standard/white point type parameters
Ogeon opened this issue · 1 comments
Description
Change all color types to have the component type parameter first and the meta type parameter (standard or white point) second. For example Rgb<Srgb, f32>
would become Rgb<f32, Srgb>
. The same goes if the type has multiple component types, like a separate alpha type. They would all be moved to the beginning.
See the motivation below for my hypothesis, but it would be interesting to know if other people have the same impression. Have you found yourself specifying more type parameters than should be necessary? Or adding a type alias to skip it? Or the opposite situation, that it's better as it is?
Motivation
This may seem insignificant, and that's what I pretty much thought until more recently, but it would likely make the types more ergonomic when using the default meta types. My experience so far shows that the component type varies the most, while the standard or white point is more likely to never change at all. The problem with the current order is that one has to specify the meta type to get to the component type in the list. For example let color: Hsv<_, f32> = ...
or let color: Hsv<Srgb, f32> = ...
, while the proposed order would allow let color: Hsv<f32> = ...
. This pops up now and again when there isn't a type alias that specifies the first parameter.
This is still on the table and I would also like to remove the default component type. The meta type may still make sense with a default, for the same reason as the swap makes sense.
struct Rgb<T, S = Srgb> { /*...*/ }
type Rgba<T, A = T, S = Srgb> = Alpha<Rgb<T, S>, A>;
I would say that if you're changing the meta type more than very temporarily, it's usually better to make an alias for the new configuration.