-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
Considering Color.fromRGBA instead of fromARGB #5205
Comments
cc @Hixie |
Is the "instead" part important or would Color.fromRGBA in addition to Color.fromARGB be acceptable?
It's how Skia prefers to pack the bits. |
Having two really close names ( |
CSS doesn't have a way to provide ARGB as a single hex code, does it? Just In which case we could have |
The same developer also commented that our handling of Alpha as a byte instead of a float felt odd coming from a CSS background. So fromRGBA might need to be (byte, byte, byte, float) to feel like CSS. |
Agreed. |
We're inconsistent about where we use a byte or a float. We should make sure we're consistent. (Typically we call the float "opacity" and the byte "alpha" but I'm not sure how consistent we are about that.) |
I think we should use that convention in general but in this specific case I think we should still call it fromRGBA (not fromRGBO or fromRgbAndOpacity) because then it matches CSS, which is the point. The documentation for that method should only refer to the fourth argument as the "opacity" though. |
(Looking at this with fresh eyes, I must admit that I'm not sure I feel as strongly about my last comment as I did when I wrote it. Maybe Color.fromRGBO is the way to go, for internal consistency.) |
@Hixie says |
Not sure how to get from opacity (which is a double) to the internal representation (which is an int) as a const expression... |
Sometimes it is convenient to construct a color from an opacity rather than an alpha value. Unfortunately, this constructor cannot be const because there's no const way to convert from a double to the internal representation of a Color, which is an int. Fixes flutter/flutter#5205
Sometimes it is convenient to construct a color from an opacity rather than an alpha value. Fixes flutter/flutter#5205
Sometimes it is convenient to construct a color from an opacity rather than an alpha value. Fixes flutter/flutter#5205
Sometimes it is convenient to construct a color from an opacity rather than an alpha value. Fixes flutter/flutter#5205
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Feedback from a developer familiar with the web. They noticed that Flutter uses "ARGB" (for example, https://docs.flutter.io/flutter/rendering/Color/Color.fromARGB.html) but the web uses "RGBA" (for example, in CSS).
To more easily leverage the color converters out there, and existing docs around color and the web, Flutter could consider thinking in "RGBA" instead of "ARGB".
(not sure if there was a reason we went with ARGB?)
The text was updated successfully, but these errors were encountered: