-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Better hex to rgba conversation #1665
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
Comments
Could you please elaborate on why exactly you think that |
You can pass 0.2 to the fade function... |
We can but the result is |
I don't think that For my opinion, body {
rgba(51, 153, 204) // rgba(51, 153, 204, 1)
rgba(51, 153, 204, 0.2) // rgba(51, 153, 204, 0.2)
rgba(51, 153, 204, 20%) // rgba(51, 153, 204, 0.2)
rgba(#3399cc) // rgba(51, 153, 204, 1)
rgba(#3399cc, 0.2) // rgba(51, 153, 204, 0.2)
rgba(#3399cc, 20%) // rgba(51, 153, 204, 0.2)
} |
I'm not sure if thats a bug or not, I thought you could pass 0.2 or 20% into fade. I think the thinking behind fade was that we have functions to allow you to modify each component, e.g. red, green, blue and I assume we went for fade instead of alpha to not interfere with so I don't think fade is inconsistent if you think of it in the right way. In terms of your rgba examples, allowing missing off the alpha component seems a little dangerous.. I see that as someone who intended to add an alpha component and then forgot - so I think it might be useful showing an error. Allowing 20% as the last argument to rgba seems okay, as does rgba(#3399cc, 0.2) but we have to ask ourselves how much benefit this gives users versus the complexity it adds to the language.. In addition.. you seem to not like fade because you are considering that you are converting a hex value to an rgba value.. and yet at the moment rgba(51, 153, 204, 1) becomes #3399cc.. and why shouldn't it if we are compressing the output? |
I agree with @lukeapage, I think fade is appropriate. rgba as a function name sounds like something that would simply define a colour, not something to adjust the transparency of an existing one. I do think the 0.2/20% thing is a bug though. |
I think most of @panych's examples are all reasonable ways of defining an rgba colour, but I foresee problems with having it replace fade. For example, what should this do?
should that result in no change to transparency or a change to 0.04? There is no ambiguity when using fade in that situation. |
I would suggest to live
Agree
I still thinks that @rgb: rgb(255, 200, 200); // #ffc8c8
// it throws an error now, but it will be nice if makes an 'rgba(255, 200, 200, 0.5)'
@rgba: rgba(@rgb, 0.5); // So at the end the list of accepted values: body {
rgba(51, 153, 204) // error
rgba(51, 153, 204, 0.2) // rgba(51, 153, 204, 0.2)
rgba(51, 153, 204, 20%) // error
rgba(#3399cc) // error
rgba(#3399cc, 0.2) // rgba(51, 153, 204, 0.2)
rgba(#3399cc, 20%) // error
} About alpha-hex: it's looks like there is no hex alpha format now: http://www.w3.org/TR/css3-color |
Not now but sometimes they come back: http://dev.w3.org/csswg/css-color/#hex-notation
It will also most likely become valid CSS syntax. |
8-digit hex has been around before in IE, except that it was |
I like |
I don't think color: hexa(rgb(0.5, 0.5, 0.5), 50%);
color: rgba(hsv(90, 100%, 50%), 50%); Following that logic we'd end up with Aside from the percentage thing, I don't think any of these names have sufficient merit. |
+1 |
Everyone thinks differently, and Anyway, I was never suggesting that we should get rid of |
I'm a bit lost here on this. Is this waiting implementation or have people given up and generally think it is no longer needed? |
I think |
Interestingly, I came across this, when I was seeing if there was a solution to issue #2379. (Of course, that requires converting a decimal alpha unit to hex, which we don't currently have.) _EDIT: Oops, I forgot about argb()!_ On this, I think the original issuer was confused because it seemed that fade was for converting hex to rgba. It is but only as a necessity; we just have to convert from hex to either rgba or hsla to represent the new color generated by fade(). So it doesn't really have anything to do with hex conversion. Fade() is for setting the alpha channel of a color. So, as it stands, agreed this issue seems closable. |
So let's finally close it. There's no issue here ( |
Feature request: better hex to rgba conversation.
Task: compact way to convert HEX color with transparency to rgba
Now there are two ways to do that:
I think that
fade
function is not very appropriate here and we can create new function for this task or updatergba
. Example:The text was updated successfully, but these errors were encountered: