Commit 16ed6eae by Aaron Leung

Implemented 'complement' built-in.

parent 1154b116
...@@ -120,6 +120,7 @@ namespace Sass { ...@@ -120,6 +120,7 @@ namespace Sass {
register_function(saturate_sig, saturate); register_function(saturate_sig, saturate);
register_function(desaturate_sig, desaturate); register_function(desaturate_sig, desaturate);
register_function(grayscale_sig, grayscale); register_function(grayscale_sig, grayscale);
register_function(complement_sig, complement);
register_function(invert_sig, invert); register_function(invert_sig, invert);
// Opacity Functions // Opacity Functions
register_function(alpha_sig, alpha); register_function(alpha_sig, alpha);
......
...@@ -430,6 +430,26 @@ namespace Sass { ...@@ -430,6 +430,26 @@ namespace Sass {
result[3].numeric_value()); result[3].numeric_value());
} }
extern Signature complement_sig = "complement($color)";
Node complement(const Node parameter_names, Environment& bindings, Node_Factory& new_Node) {
Node color(bindings[parameter_names[0].token()]);
if (color.type() != Node::numeric_color) throw_eval_error("argument to 'complement' must be a color", color.path(), color.line());
Node hsl_color(rgb_to_hsl(color[0].numeric_value(),
color[1].numeric_value(),
color[2].numeric_value(),
new_Node));
Node result(hsla_impl(hsl_color[0].numeric_value() - 180, // other side of the color wheel
hsl_color[1].numeric_value(),
hsl_color[2].numeric_value(),
color[3].numeric_value(),
new_Node));
return new_Node(color.path(), color.line(),
result[0].numeric_value(),
result[1].numeric_value(),
result[2].numeric_value(),
result[3].numeric_value());
}
extern Signature invert_sig = "invert($color)"; extern Signature invert_sig = "invert($color)";
Node invert(const Node parameter_names, Environment& bindings, Node_Factory& new_Node) { Node invert(const Node parameter_names, Environment& bindings, Node_Factory& new_Node) {
Node orig(bindings[parameter_names[0].token()]); Node orig(bindings[parameter_names[0].token()]);
......
...@@ -119,6 +119,9 @@ namespace Sass { ...@@ -119,6 +119,9 @@ namespace Sass {
extern Signature grayscale_sig; extern Signature grayscale_sig;
Node grayscale(const Node, Environment&, Node_Factory&); Node grayscale(const Node, Environment&, Node_Factory&);
extern Signature complement_sig;
Node complement(const Node, Environment&, Node_Factory&);
extern Signature invert_sig; extern Signature invert_sig;
Node invert(const Node, Environment&, Node_Factory&); Node invert(const Node, Environment&, Node_Factory&);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment