Skip to content

GPUColor: remove sequence overload from the union#1079

Closed
kainino0x wants to merge 1 commit intogpuweb:mainfrom
kainino0x:gpucolor-remove-sequence
Closed

GPUColor: remove sequence overload from the union#1079
kainino0x wants to merge 1 commit intogpuweb:mainfrom
kainino0x:gpucolor-remove-sequence

Conversation

@kainino0x
Copy link
Contributor

@kainino0x kainino0x commented Sep 15, 2020

The overload adds complexity for not much benefit ({r: 0, g: 0, b: 0, a: 0} vs [0, 0, 0, 0]).
More importantly, in certain contexts, the ordering of [0, 0, 0, 0] is not obvious. For example, when used as the clear color of a BGRA texture: does it use the "canonical" RGBA ordering, or does it match the format? This removes the ambiguity.

We previously decided to add this overload for convenience, and it was done in #319. However I think I was the main voice pushing for it. I still like the convenience, but unfortunately I think the ambiguity is a bigger problem.


Preview | Diff

The overload adds complexity for not much benefit
(`{r: 0, g: 0, b: 0, a: 0}` vs `[0, 0, 0, 0]`).
More importantly, in certain contexts, the ordering of `[0, 0, 0, 0]` is
not obvious. For example, when used as the clear color of a BGRA
texture: does it use the "canonical" RGBA ordering, or does it match the
format? This removes the ambiguity.
@kainino0x
Copy link
Contributor Author

inb4 being asked to change this to CSS color strings later on

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

me always appreciates strictly disciplined APIs :)

@kdashg
Copy link
Contributor

kdashg commented Sep 21, 2020

{r: 0, g: 0, b: 0, a: 0} is so much worse ergonomically than [0,0,0,0], and I don't think it's that much more explicit.
If we only had one, I would prefer [0,0,0,0].

@kainino0x
Copy link
Contributor Author

@jdashg what if we did something like Metal's MTLClearColor MTLClearColorMake(double red, double green, double blue, double alpha)? E.g. GPU.makeColor(double red, double green, double blue, double alpha) -> GPUColor?

@kainino0x kainino0x closed this Dec 17, 2020
@kainino0x kainino0x deleted the gpucolor-remove-sequence branch December 17, 2020 00:32
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.

4 participants