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

Does there need to be a way to get the RGB components as [0,255] ? #12

Open
2 tasks
avh4 opened this issue Sep 10, 2018 · 3 comments
Open
2 tasks

Does there need to be a way to get the RGB components as [0,255] ? #12

avh4 opened this issue Sep 10, 2018 · 3 comments
Labels
community review wanted Seeking input from everyone discussion

Comments

@avh4
Copy link
Owner

avh4 commented Sep 10, 2018

Questions:

  • Is there a use case for getting the RGB components as [0,255]? How common is it?
  • If common, should alpha be provided as [0,255], or [0.0,1.0], or both?

Currently, there is toHex, which does the conversion to integers, but only provides the result as a hex string. Is this sufficient for common needs? It is also currently possible to use toRgba and convert the components yourself using (*) 255 >> round.

We could possibly add something like the following:

toRgb255 : Color -> { red : Int, green : Int, blue : Int, alpha : Float }
@avh4 avh4 added this to the 1.0.0 milestone Sep 10, 2018
@avh4 avh4 mentioned this issue Sep 10, 2018
@avh4 avh4 mentioned this issue Sep 10, 2018
7 tasks
@avh4 avh4 added the community review wanted Seeking input from everyone label Sep 10, 2018
@avh4 avh4 removed this from the 1.0.0 milestone Sep 11, 2018
@avh4
Copy link
Owner Author

avh4 commented Sep 11, 2018

Given there aren't any clear use-cases documented yet, I think this can wait for consideration in 1.1.0.

@Chadtech
Copy link

I have a project in 0.18 that uses the old Color package extensively. Its a paint drawing application (ctpaint.org/app). Here are some cases in that project where I think a Color to 0-255 number string would be useful:

  1. My project has a color picker. In the color picker there are html input fields for the HSL and the RGB values. I have a Color in the Model, but in the input fields, the Color is represented as 0-255 numbers the user can modify.
  2. The project stores colors in a palette that the user choose to draw in on the main canvas. All colors are stored in the Elm Color type and draws colors from the palette onto a native JS canvas, which is in the format of 0-255 numbers. To do the drawing operations in the paint program I need to translate from the Color as its stored in the palette to the 0-255 number format for the canvas.

@tgelu
Copy link

tgelu commented Jun 2, 2020

The simplest use case is to use it with elm-css. At the moment this is quite inconvenient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community review wanted Seeking input from everyone discussion
Projects
None yet
Development

No branches or pull requests

3 participants