Permalink
Browse files

Throw a more descriptive error for invalid colors in ops. Fixes #309

  • Loading branch information...
1 parent 15140e4 commit cb177b7a2484b8bf95807227538b742ed4cc4044 @tmcw tmcw committed Oct 23, 2013
View
@@ -54,60 +54,71 @@ tree.functions = {
}
},
hue: function (color) {
+ if (!('toHSL' in color)) return null;
return new tree.Dimension(Math.round(color.toHSL().h));
},
saturation: function (color) {
+ if (!('toHSL' in color)) return null;
return new tree.Dimension(Math.round(color.toHSL().s * 100), '%');
},
lightness: function (color) {
+ if (!('toHSL' in color)) return null;
return new tree.Dimension(Math.round(color.toHSL().l * 100), '%');
},
alpha: function (color) {
+ if (!('toHSL' in color)) return null;
return new tree.Dimension(color.toHSL().a);
},
saturate: function (color, amount) {
+ if (!('toHSL' in color)) return null;
var hsl = color.toHSL();
hsl.s += amount.value / 100;
hsl.s = clamp(hsl.s);
return hsla(hsl);
},
desaturate: function (color, amount) {
+ if (!('toHSL' in color)) return null;
var hsl = color.toHSL();
hsl.s -= amount.value / 100;
hsl.s = clamp(hsl.s);
return hsla(hsl);
},
lighten: function (color, amount) {
+ if (!('toHSL' in color)) return null;
var hsl = color.toHSL();
hsl.l += amount.value / 100;
hsl.l = clamp(hsl.l);
return hsla(hsl);
},
darken: function (color, amount) {
+ if (!('toHSL' in color)) return null;
var hsl = color.toHSL();
hsl.l -= amount.value / 100;
hsl.l = clamp(hsl.l);
return hsla(hsl);
},
fadein: function (color, amount) {
+ if (!('toHSL' in color)) return null;
var hsl = color.toHSL();
hsl.a += amount.value / 100;
hsl.a = clamp(hsl.a);
return hsla(hsl);
},
fadeout: function (color, amount) {
+ if (!('toHSL' in color)) return null;
var hsl = color.toHSL();
hsl.a -= amount.value / 100;
hsl.a = clamp(hsl.a);
return hsla(hsl);
},
spin: function (color, amount) {
+ if (!('toHSL' in color)) return null;
var hsl = color.toHSL();
var hue = (hsl.h + amount.value) % 360;
@@ -0,0 +1,3 @@
+#world {
+ polygon-fill: spin(#f00f00f, 10);
+}
@@ -0,0 +1 @@
+invalid_color_in_fn.mss:2:34 incorrect arguments given to spin()

0 comments on commit cb177b7

Please sign in to comment.