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

Swap component and standard/white point type parameters #281

Open
Ogeon opened this issue Apr 26, 2022 · 1 comment
Open

Swap component and standard/white point type parameters #281

Ogeon opened this issue Apr 26, 2022 · 1 comment
Labels
definitely breaking Issues that are known before-hand to be a breaking change
Milestone

Comments

@Ogeon
Copy link
Owner

Ogeon commented Apr 26, 2022

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.

@Ogeon Ogeon added the definitely breaking Issues that are known before-hand to be a breaking change label Apr 16, 2023
@Ogeon
Copy link
Owner Author

Ogeon commented Nov 4, 2023

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.

@Ogeon Ogeon added this to the 0.8.0 milestone Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
definitely breaking Issues that are known before-hand to be a breaking change
Projects
None yet
Development

No branches or pull requests

1 participant