UNPKG

chroma-js

Version:

JavaScript library for color conversions

14 lines (12 loc) 375 B
const Color = require('../Color'); const {type} = require('../utils'); Color.prototype.alpha = function(a, mutate=false) { if (a !== undefined && type(a) === 'number') { if (mutate) { this._rgb[3] = a; return this; } return new Color([this._rgb[0], this._rgb[1], this._rgb[2], a], 'rgb'); } return this._rgb[3]; }