UNPKG

chroma-js

Version:

JavaScript library for color conversions

13 lines (11 loc) 290 B
const Color = require('../Color'); 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'); } }