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

coloralpha #531

Closed
yukulele opened this issue Dec 19, 2011 · 6 comments
Closed

coloralpha #531

yukulele opened this issue Dec 19, 2011 · 6 comments

Comments

@yukulele
Copy link

hi,
I suggest a 'coloralpha' function to add alpha channel to color :

exemple :

LESS input :

body
{
     background-color : coloralpha(#ffcc00 , 0.5);
     color : coloralpha(blue , 0.3);
}

CSS output :

body
{
     background : rgba(255 , 204 , 0 , 0.5);
     color : rgba(0 , 0 , 255 , 0.3
}

actualy I need to do this ugly workaround :

body
{
     @col:#ffcc00
     background : hsla(hue(@col) , saturation(@col) , lightness(@col) , 0.5);
     color : hsla(hue(red) , saturation(red) , lightness(red) , 0.5);
}
@cloudhead
Copy link
Member

It's called fade, sorry it's not in the docs: fade(blue, 50%)

@yukulele
Copy link
Author

Nice !

Maybe it would be better to use 0-1 based value if their is no '%' char (like some standard css property : opacity, rgba, shla, gradient...)

exemple : fade(red,25%) = fade(red,0.25)
idem for all "%" functions (lighten, darken, saturate, desaturate, fadeout...)

@cloudhead
Copy link
Member

yea, good idea, will look into that.

@StreetStrider
Copy link

Hmm, I'm completely agree with topic starter. It is good to see this issue answered. Not having a simple alpha function is a pain. Here's two things I want to note (imo):

  1. It should use [0..1] value for alpha.
  2. Value should be absolute.

For now when I want to mix alpha in color I'm using something (not so pretty construction) like this:

rgba(red(@color), green(@color), blue(@color), @opacity)

Thanks. I'll look into this thread sometimes.

@seven-phases-max
Copy link
Member

@StreetStrider see fade.

  1. To use [0...1] value just write it as color: fade(@color, @opacity * 100%);.
  2. The value is absolute.
    Also see Better hex to rgba conversation #1665.

@StreetStrider
Copy link

@seven-phases-max, thanks, I didn't notice that before, only fadein, fadeout.
Thanks for the heads up too.

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

No branches or pull requests

4 participants