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

rgbaFromHex #68

Closed
rtfeldman opened this issue Jan 21, 2016 · 6 comments
Closed

rgbaFromHex #68

rtfeldman opened this issue Jan 21, 2016 · 6 comments

Comments

@rtfeldman
Copy link
Owner

This needs to be implemented: https://github.com/rtfeldman/elm-css/blob/master/src/Css.elm#L635-L643

Semantics:

  • Should work with hexadecimal strings of length 3, 4, 6, or 8 (the 4 and 8 would include alpha, just like in CSS)
  • If you give it a crazy value, like you use non-hexadecimal chars or a crazy length, it should return appropriate warning messages

Relatedly, there should probably also be a rgbaFromHsla that works similarly except for HSLA colors.

@lukewestby
Copy link
Collaborator

These functions should return a Color property with an rgba(r,g,b,a) value?

@rtfeldman
Copy link
Owner Author

It's actually that I changed Color to include red, green, and blue values, so you can now go (rgb 22, 23,224).red and get back 22. This lets people do color mixing and such.

This is where the function lives now: https://github.com/rtfeldman/elm-css/blob/master/src/Css.elm#L844-L854

Incidentally, here's the equivalent for hsl and hsla: https://github.com/rtfeldman/elm-css/blob/master/src/Css.elm#L860-L867

@lukewestby
Copy link
Collaborator

got it! i can do this one tonight or tomorrow.

@rtfeldman
Copy link
Owner Author

Awesome! 😸

@rtfeldman
Copy link
Owner Author

Closing in favor of #76 cc @lukewestby - turns out having the records have a color : Color field (as in Color from core) will be more beneficial to people writing generic color mixing libraries, and I think it makes more sense to optimize for that use case than for the "pulling out red, green, or blue on an individual basis" use case.

@lukewestby
Copy link
Collaborator

sweet! that's awesome 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants