color() function parses color string

This commit is contained in:
Alexis Sellier
2011-12-18 17:29:40 +01:00
parent 6c6cdcb839
commit eadc0d8704
4 changed files with 11 additions and 2 deletions

View File

@@ -170,6 +170,13 @@ tree.functions = {
},
percentage: function(n) {
return new(tree.Dimension)(n.value * 100, '%');
},
color: function (n) {
if (n instanceof tree.Quoted) {
return new(tree.Color)(n.value.slice(1));
} else {
throw { type: "Argument", message: "argument must be a string" };
}
}
};