chroma-js
Version:
JavaScript library for color conversions
14 lines (12 loc) • 352 B
JavaScript
const Color = require('../Color');
Color.prototype.get = function(mc) {
const [mode,channel] = mc.split('.');
const src = this[mode]();
if (channel) {
const i = mode.indexOf(channel);
if (i > -1) return src[i];
throw new Error(`unknown channel ${channel} in mode ${mode}`);
} else {
return src;
}
}