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

Include invert to color functions #589

Closed
Oskariok opened this issue Jan 21, 2012 · 6 comments
Closed

Include invert to color functions #589

Oskariok opened this issue Jan 21, 2012 · 6 comments

Comments

@Oskariok
Copy link

Currently I'm using
color: hsl(hue(@black), saturation(@black), 100 - lightness(@black));
to invert colors but
color: invert(@color)
would be much better syntax for the job.

The code for function:

    invert: function (color) {
        var rgb = [255 - color.rgb[0],
                   255 - color.rgb[1],
                   255 - color.rgb[2]]; 
        return new(tree.Color)(rgb);
    },  

I tested it with less.js 1.2.1 so it works

@Oskariok
Copy link
Author

Oskariok commented Feb 2, 2012

Updated original post

@ascottmccauley
Copy link

+1 for this:
Just to clarify, do you mean that you are using

hsl(hue(@color), saturation(@color), 100 - lightness(@color));

@srsgores
Copy link

srsgores commented May 2, 2013

+1 as well.

@lukeapage
Copy link
Member

this can now be achieved with negation

http://lesscss.org/functions/#color-blending-negation

@seven-phases-max
Copy link
Member

Not really the negation. The javascript code posted by @Oskariok is simple Less (#fff - @color) or equal difference(#fff, @color). However the Less code suggested by @ascottmccauley later is not the same, it only inverts colour lightness (so Less and javascript snippets of the first post do not match each other). "Invert lightness" can also be achieved with less verbose: spin((#fff - @color), 180);

@lukeapage
Copy link
Member

okay well either way..

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

5 participants