leafo/lessphp — Issue #168: feature request; builtin function invert()
Author: vanderlee
Created: 2011-12-20 19:30:43+00:00
State: open

An invert() builtin that basically subtracts each individual color channel from 255.
rgb(255, 222, 0) would become rgb(0, 33, 255);

When used in combination with the builtin spin(), you can make intensity-only negatives:
@negative: spin(invert(@color), 180);

Alternatively, a builtin that does both at once would be nice too, considering you're most likely going to use this to create contrasting colors from the same palette.

Somewhat related, a function that could return black #000000 or white #ffffff based on the intensity of a color would be nice too; useful for text-shadows. Something like a contrast(color, percent) would be easy and could be used to this effect in combination with my proposed invert() and the already present desaturate();