image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
57 lines • 1.29 kB
JavaScript
export class PvrColorRgb {
get r() {
return this._r;
}
get g() {
return this._g;
}
get b() {
return this._b;
}
constructor(r = 0, g = 0, b = 0) {
this._r = r;
this._g = g;
this._b = b;
}
static from(other) {
return new PvrColorRgb(other._r, other._g, other._b);
}
copy() {
return PvrColorRgb.from(this);
}
setMin(c) {
if (c._r < this._r) {
this._r = c._r;
}
if (c._g < this._g) {
this._g = c._g;
}
if (c._b < this._b) {
this._b = c._b;
}
}
setMax(c) {
if (c._r > this._r) {
this._r = c._r;
}
if (c._g > this._g) {
this._g = c._g;
}
if (c._b > this._b) {
this._b = c._b;
}
}
mul(x) {
return new PvrColorRgb(this._r * x, this._g * x, this._b * x);
}
add(x) {
return new PvrColorRgb(this._r + x._r, this._g + x._g, this._b + x._b);
}
sub(x) {
return new PvrColorRgb(this._r - x._r, this._g - x._g, this._b - x._b);
}
dotProd(x) {
return this._r * x._r + this._g * x._g + this._b * x._b;
}
}
//# sourceMappingURL=pvr-color-rgb.js.map