Added the square root function.

This commit is contained in:
Salehen Rahman
2013-01-01 19:41:51 -08:00
committed by Luke Page
parent 782d00972a
commit d56e0a476d
3 changed files with 5 additions and 0 deletions

View File

@@ -227,6 +227,9 @@ tree.functions = {
floor: function (n) {
return this._math(Math.floor, n);
},
sqrt: function (n) {
return this._math(Math.sqrt, n);
},
_math: function (fn, n) {
if (n instanceof tree.Dimension) {
return new(tree.Dimension)(fn(parseFloat(n.value)), n.unit);

View File

@@ -58,6 +58,7 @@
rounded-percentage: 10%;
ceil: 11px;
floor: 12px;
sqrt: 5px;
percentage: 20%;
color: #ff0011;
tint: #898989;

View File

@@ -64,6 +64,7 @@
rounded-percentage: round(10.2%);
ceil: ceil(10.1px);
floor: floor(12.9px);
sqrt: sqrt(25px);
percentage: percentage(10px / 50);
color: color("#ff0011");
tint: tint(#777777, 13);