fieldkit
Version:
Basic building blocks for computational design projects. Written in CoffeeScript for browser and server environments.
79 lines (60 loc) • 1.62 kB
JavaScript
// Generated by CoffeeScript 1.6.3
/*
*/
(function() {
var Color;
Color = (function() {
Color.prototype.r = 1;
Color.prototype.g = 1;
Color.prototype.b = 1;
Color.prototype.a = 1;
function Color(r, g, b, a) {
this.r = r != null ? r : 1;
this.g = g != null ? g : 1;
this.b = b != null ? b : 1;
this.a = a != null ? a : 1;
}
Color.prototype.set = function(color) {
this.r = color.r;
this.g = color.g;
this.b = color.b;
this.a = color.a;
return this;
};
Color.prototype.set3 = function(r, g, b) {
this.r = r;
this.g = g;
this.b = b;
return this;
};
Color.prototype.randomize = function() {
this.r = Math.random();
this.g = Math.random();
this.b = Math.random();
return this;
};
Color.prototype.clone = function() {
return new Color(this.r, this.g, this.b, this.a);
};
Color.prototype.equals = function(other) {
if (other == null) {
return false;
}
return this.r === other.r && this.g === other.g && this.b === other.b && this.a === other.a;
};
Color.prototype.toCSS = function() {
var b, g, r;
r = Math.floor(255 * this.r);
g = Math.floor(255 * this.g);
b = Math.floor(255 * this.b);
return "rgba(" + r + "," + g + "," + b + "," + this.a + ")";
};
Color.prototype.toString = function() {
return "fk.Color(" + this.r + "," + this.g + "," + this.b + "," + this.a + ")";
};
return Color;
})();
module.exports = {
Color: Color
};
}).call(this);