c0lor
Version:
Color space conversions
29 lines (23 loc) • 523 B
JavaScript
var O, atan2, labPrototype, sqrt;
O = require("ut1l/create/object");
sqrt = Math.sqrt;
atan2 = Math.atan2;
labPrototype = {
LCh: function(T) {
if (T == null) {
T = require("./LCh")();
}
T.L = this.L;
T.C = sqrt(this.a * this.a + this.b * this.b);
T.h = atan2(this.b, this.a);
return T;
},
toString: function() {
return "L=" + this.L + ", a=" + this.a + ", b=" + this.b;
}
};
module.exports = O((function(L, a, b) {
this.L = L;
this.a = a;
this.b = b;
}), labPrototype);