How to use the color.prototype function in color

To help you get started, we’ve selected a few color examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
}

Color.prototype.mixed = function(bg) {
    // https://stackoverflow.com/a/11615135/3909342
    if (this.alpha() !== 1) {
        let a = 1 - this.alpha();
        let r = Math.round((this.alpha() * (this.red() / 255) + (a * (bg.red() / 255))) * 255);
        let g = Math.round((this.alpha() * (this.green() / 255) + (a * (bg.green() / 255))) * 255);
        let b = Math.round((this.alpha() * (this.blue() / 255) + (a * (bg.blue() / 255))) * 255);
        return Color.rgb(r, g, b)
    } else {
        return this
    }
}

Color.prototype.protanopia = function() {
    let rgb = blinder.protanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranopia = function() {
    let rgb = blinder.deuteranopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanopia = function() {
    let rgb = blinder.tritanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.protanomaly = function() {
    let rgb = blinder.protanomaly(this.hex(), true);
github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
var reverseKeywords = {};
for (var key in cssKeywords) {
	if (cssKeywords.hasOwnProperty(key)) {
		reverseKeywords[cssKeywords[key]] = key;
	}
}

Color.prototype.cssname = function() {
    const reversed = reverseKeywords[this.color];
    if (reversed) {
        return reversed;
    }
    return null
}

Color.prototype.mixed = function(bg) {
    // https://stackoverflow.com/a/11615135/3909342
    if (this.alpha() !== 1) {
        let a = 1 - this.alpha();
        let r = Math.round((this.alpha() * (this.red() / 255) + (a * (bg.red() / 255))) * 255);
        let g = Math.round((this.alpha() * (this.green() / 255) + (a * (bg.green() / 255))) * 255);
        let b = Math.round((this.alpha() * (this.blue() / 255) + (a * (bg.blue() / 255))) * 255);
        return Color.rgb(r, g, b)
    } else {
        return this
    }
}

Color.prototype.protanopia = function() {
    let rgb = blinder.protanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}
github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
let a = 1 - this.alpha();
        let r = Math.round((this.alpha() * (this.red() / 255) + (a * (bg.red() / 255))) * 255);
        let g = Math.round((this.alpha() * (this.green() / 255) + (a * (bg.green() / 255))) * 255);
        let b = Math.round((this.alpha() * (this.blue() / 255) + (a * (bg.blue() / 255))) * 255);
        return Color.rgb(r, g, b)
    } else {
        return this
    }
}

Color.prototype.protanopia = function() {
    let rgb = blinder.protanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranopia = function() {
    let rgb = blinder.deuteranopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanopia = function() {
    let rgb = blinder.tritanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.protanomaly = function() {
    let rgb = blinder.protanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranomaly = function() {
    let rgb = blinder.deuteranomaly(this.hex(), true);
github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
Color.prototype.protanomaly = function() {
    let rgb = blinder.protanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranomaly = function() {
    let rgb = blinder.deuteranomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanomaly = function() {
    let rgb = blinder.tritanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.achromatopsia = function() {
    let rgb = blinder.achromatopsia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.achromatomaly = function() {
    let rgb = blinder.achromatomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.isHex = function(string) {
    let abbr = /^#([a-f0-9]{3})$/i;
    let hex = /^#([a-f0-9]{6})$/i;
    return (string.match(hex) || string.match(abbr))
}

Color.isHexA = function(string) {
github stayradiated / termcolors / lib / color.js View on Github external
var _ = require('lodash');
var Color = require('color');

Color.prototype.avgRgbArray = function () {
  return this.rgbArray().map(function (value) {
    return value / 255;
  });
};

Color.prototype.doubleHex = function () {
  var hex = this.hexString().slice(1);
  var r = hex.slice(0, 2);
  var g = hex.slice(2, 4);
  var b = hex.slice(4, 6);
  return r + r + g + g + b + b;
};

Color.prototype.doubleHexString = function () {
  return '#' + this.doubleHex();
};

module.exports = Color;
github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
Color.prototype.deuteranomaly = function() {
    let rgb = blinder.deuteranomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanomaly = function() {
    let rgb = blinder.tritanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.achromatopsia = function() {
    let rgb = blinder.achromatopsia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.achromatomaly = function() {
    let rgb = blinder.achromatomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.isHex = function(string) {
    let abbr = /^#([a-f0-9]{3})$/i;
    let hex = /^#([a-f0-9]{6})$/i;
    return (string.match(hex) || string.match(abbr))
}

Color.isHexA = function(string) {
    let abbr = /^#([a-f0-9]{3,4})$/i;
    let hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
    return (string.match(hex) || string.match(abbr))
}
github stayradiated / termcolors / lib / color.js View on Github external
var _ = require('lodash');
var Color = require('color');

Color.prototype.avgRgbArray = function () {
  return this.rgbArray().map(function (value) {
    return value / 255;
  });
};

Color.prototype.doubleHex = function () {
  var hex = this.hexString().slice(1);
  var r = hex.slice(0, 2);
  var g = hex.slice(2, 4);
  var b = hex.slice(4, 6);
  return r + r + g + g + b + b;
};

Color.prototype.doubleHexString = function () {
  return '#' + this.doubleHex();
};
github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
Color.prototype.deuteranopia = function() {
    let rgb = blinder.deuteranopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanopia = function() {
    let rgb = blinder.tritanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.protanomaly = function() {
    let rgb = blinder.protanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranomaly = function() {
    let rgb = blinder.deuteranomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanomaly = function() {
    let rgb = blinder.tritanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.achromatopsia = function() {
    let rgb = blinder.achromatopsia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.achromatomaly = function() {
    let rgb = blinder.achromatomaly(this.hex(), true);
github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
} else {
        return this
    }
}

Color.prototype.protanopia = function() {
    let rgb = blinder.protanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranopia = function() {
    let rgb = blinder.deuteranopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanopia = function() {
    let rgb = blinder.tritanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.protanomaly = function() {
    let rgb = blinder.protanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranomaly = function() {
    let rgb = blinder.deuteranomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanomaly = function() {
    let rgb = blinder.tritanomaly(this.hex(), true);
github ThePacielloGroup / CCAe / src / CCAcolor.js View on Github external
Color.prototype.protanopia = function() {
    let rgb = blinder.protanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranopia = function() {
    let rgb = blinder.deuteranopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanopia = function() {
    let rgb = blinder.tritanopia(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.protanomaly = function() {
    let rgb = blinder.protanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.deuteranomaly = function() {
    let rgb = blinder.deuteranomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.tritanomaly = function() {
    let rgb = blinder.tritanomaly(this.hex(), true);
    return Color.rgb(rgb.R, rgb.G, rgb.B)
}

Color.prototype.achromatopsia = function() {
    let rgb = blinder.achromatopsia(this.hex(), true);