chroma-js
Version:
JavaScript library for color conversions
13 lines (11 loc) • 337 B
JavaScript
import Color from '../Color.js';
Color.prototype.premultiply = function (mutate = false) {
const rgb = this._rgb;
const a = rgb[3];
if (mutate) {
this._rgb = [rgb[0] * a, rgb[1] * a, rgb[2] * a, a];
return this;
} else {
return new Color([rgb[0] * a, rgb[1] * a, rgb[2] * a, a], 'rgb');
}
};