mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
functions.js init
This commit is contained in:
25
lib/less/functions.js
Normal file
25
lib/less/functions.js
Normal file
@@ -0,0 +1,25 @@
|
||||
functions = {
|
||||
rgb: function (r, g, b) {
|
||||
return this.rgba(r, g, b, 1.0);
|
||||
},
|
||||
rgba: function (r, g, b, a) {
|
||||
return new(node.Color)([r, g, b, a]);
|
||||
},
|
||||
hsl: function (h, s, l) {
|
||||
return this.hsla(h, s, l, 1.0);
|
||||
},
|
||||
hsla: function (h, s, l, a) {
|
||||
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
||||
var m1 = l * 2 - m2;
|
||||
|
||||
return this.rgba(hue(h + 1/3), hue(h), hue(h - 1/3), a);
|
||||
|
||||
function hue(h) {
|
||||
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
|
||||
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
|
||||
else if (h * 2 < 1) return m2;
|
||||
else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6;
|
||||
else return m1;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user