Skip to content

Considering Color.fromRGBA instead of fromARGB #5205

Closed

Description

@sethladd

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?)

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 3, 2016
  2. sethladd commented on Aug 3, 2016

    @sethladd
    ContributorAuthor
  3. abarth commented on Aug 3, 2016

    @abarth
    Contributor

    Is the "instead" part important or would Color.fromRGBA in addition to Color.fromARGB be acceptable?

    not sure if there was a reason we went with ARGB?

    It's how Skia prefers to pack the bits.

  4. a14n commented on Aug 4, 2016

    @a14n
    Contributor

    Having two really close names (fromRGBA and fromARGB) with the same types for parameters could be error prone IMHO.

  5. Hixie commented on Aug 4, 2016

    @Hixie
    Contributor

    CSS doesn't have a way to provide ARGB as a single hex code, does it? Just rgba(.., .., .., ...).

    In which case we could have const Color(0xAARRGGBB) and new Color.fromRGBA(rr, gg, bb, aa), where the former is significantly preferred but the latter is available when you need to switch from CSS to Flutter.

  6. eseidelGoogle commented on Aug 4, 2016

    @eseidelGoogle
    Contributor

    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.

  7. Hixie commented on Aug 4, 2016

    @Hixie
    Contributor

    Agreed.

  8. added
    c: new featureNothing broken; request for a new capability
    engineflutter/engine related. See also e: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 4, 2016
  9. added this to the milestone on Aug 4, 2016
  10. abarth commented on Aug 4, 2016

    @abarth
    Contributor

    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.)

  11. Hixie commented on Aug 4, 2016

    @Hixie
    Contributor

    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.

  12. 1 remaining item

  13. modified the milestones: , on Sep 16, 2016
  14. self-assigned this
    on Sep 19, 2016
  15. abarth commented on Sep 19, 2016

    @abarth
    Contributor

    @Hixie says Color.fromRGBO is the one true name.

  16. abarth commented on Sep 19, 2016

    @abarth
    Contributor

    Not sure how to get from opacity (which is a double) to the internal representation (which is an int) as a const expression...

  17. added a commit that references this issue on Sep 20, 2016
  18. github-actions commented on Sep 6, 2021

    @github-actions

    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 flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: API breakBackwards-incompatible API changesc: new featureNothing broken; request for a new capabilityengineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions