Returns XYZ representation of given color
@param  {Array} color  - RGBA color array [r,g,b,a]
@return {Array}        - [x,y,z] (x:0..95, y:0..100, z:0..108)
331760
function getXYZ(color) {
    var r = toXYZValue(color[0]);
    var g = toXYZValue(color[1]);
    var b = toXYZValue(color[2]);

    return [
        r * 0.4124 + g * 0.3576 + b * 0.1805,
        r * 0.2126 + g * 0.7152 + b * 0.0722,
        r * 0.0193 + g * 0.1192 + b * 0.9505
    ]
}
1137176
function whiteOrBlack( color ) {
		color = color.replace( /^#/, '' );
		for ( var i = 0, rgb = []; i <= 2; i++ )
			rgb[ i ] = parseInt( color.substr( i * 2, 2 ), 16 );
		var luma = ( 0.2126 * rgb[ 0 ] ) + ( 0.7152 * rgb[ 1 ] ) + ( 0.0722 * rgb[ 2 ] );
		return '#' + ( luma >= 165 ? '000' : 'fff' );
	}
890652
def rgb_to_xyz(colour)
      r, g, b = colour.map do |v|
          v /= 255.0
          if v > 0.04045
              v = ((v + 0.055 ) / 1.055)**2.4
          else
              v = v / 12.92
          end
          v *= 100
      end

      #Observer = 2°, Illuminant = D65
      x = r * 0.4124 + g * 0.3576 + b * 0.1805
      y = r * 0.2126 + g * 0.7152 + b * 0.0722
      z = r * 0.0193 + g * 0.1192 + b * 0.9505

      return [x, y, z]
    end
772582
function(rgb){
            var parts = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
            var hex = (parts[1]<<16|parts[2]<<8|parts[3]).toString(16);
            return "#"+Array(6-hex.length).concat([hex]).toString().replace(/,/g, 0);
        }
882462
function (colour) {
  if (!colour || !!((colour = String(colour)).indexOf("-") + 1)) {
    return {r: -1, g: -1, b: -1, opacity: -1, error: 1};
  }
  if (colour == "none") {
    return {r: -1, g: -1, b: -1, opacity: -1};
  }
  !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));
  if (!colour) {
    return {r: -1, g: -1, b: -1, opacity: -1, error: 1};
  }
  var res,
      red,
      green,
      blue,
      opacity,
      t,
      values,
      rgb = colour.match(colourRegExp);
  if (rgb) {
    if (rgb[2]) {
      blue = parseInt(rgb[2].substring(5), 16);
      green = parseInt(rgb[2].substring(3, 5), 16);
      red = parseInt(rgb[2].substring(1, 3), 16);
    }
    if (rgb[3]) {
      blue = parseInt((t = rgb[3].charAt(3)) + t, 16);
      green = parseInt((t = rgb[3].charAt(2)) + t, 16);
      red = parseInt((t = rgb[3].charAt(1)) + t, 16);
    }
    if (rgb[4]) {
      values = rgb[4].split(commaSpaces);
      red = parseFloat(values[0]);
      values[0].slice(-1) == "%" && (red *= 2.55);
      green = parseFloat(values[1]);
      values[1].slice(-1) == "%" && (green *= 2.55);
      blue = parseFloat(values[2]);
      values[2].slice(-1) == "%" && (blue *= 2.55);
      rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = parseFloat(values[3]));
      values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
    }
    if (rgb[5]) {
      values = rgb[5].split(commaSpaces);
      red = parseFloat(values[0]);
      values[0].slice(-1) == "%" && (red /= 100);
      green = parseFloat(values[1]);
      values[1].slice(-1) == "%" && (green /= 100);
      blue = parseFloat(values[2]);
      values[2].slice(-1) == "%" && (blue /= 100);
      (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
      rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = parseFloat(values[3]));
      values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
      return hsb2rgb(red, green, blue, opacity);
    }
    if (rgb[6]) {
      values = rgb[6].split(commaSpaces);
      red = parseFloat(values[0]);
      values[0].slice(-1) == "%" && (red /= 100);
      green = parseFloat(values[1]);
      values[1].slice(-1) == "%" && (green /= 100);
      blue = parseFloat(values[2]);
      values[2].slice(-1) == "%" && (blue /= 100);
      (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
      rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = parseFloat(values[3]));
      values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
      return hsl2rgb(red, green, blue, opacity);
    }
    red = Math.min(Math.round(red), 255);
    green = Math.min(Math.round(green), 255);
    blue = Math.min(Math.round(blue), 255);
    opacity = Math.min(Math.max(opacity, 0), 1);
    rgb = {r: red, g: green, b: blue};
    rgb.opacity = isFinite(opacity) ? opacity : 1;
    return rgb;
  }
  return {r: -1, g: -1, b: -1, opacity: -1, error: 1};
}
1197337
function rgba(r, g, b, a) {
	return new RGBA(r, g, b, a);
}
97696
function HSLA_TO_RGBA() {
        var h = this.h();
        var s = this.s();
        var l = this.l();
        var a = this.a();
        var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
        var p = 2 * l - q;
        var hk = h / 360;
        var t = {};
        var rgb = {};

        t.r = hk + 1 / 3;
        t.g = hk;
        t.b = hk - 1 / 3;

        var c;

        for (c in t) {
            t[c] < 0 && t[c] ++;
            t[c] > 1 && t[c] --;
        }

        for (c in t) {
            if (t[c] < 1 / 6) {
                rgb[c] = p + ((q - p) * 6 * t[c]);
            } else if (1 / 6 <= t[c] && t[c] < 0.5) {
                rgb[c] = q;
            } else if (0.5 <= t[c] && t[c] < 2 / 3) {
                rgb[c] = p + ((q - p) * 6 * (2 / 3 - t[c]));
            } else { // t[c] >= 2 / 3
                rgb[c] = p;
            }
            rgb[c] *= 255;
        }

        return kolor.rgba(rgb.r, rgb.g, rgb.b, a);
    }
603396
function _colorToRgbArray(color) {
	var originalColor, elem,
		rgb = [],
		multiple = 1;

	// Deal with complete transparency
	if (color === 'transparent') {
		color = 'rgba(0, 0, 0, 0)';
	} else if (color.match(/^([a-z]+|#[0-9a-f]+)$/gi)) {
		// Deal with hexadecimal colors and color names
		elem = document.head;
		originalColor = elem.style.color;
		elem.style.color = color;
		color = $.css(elem, 'color');
		elem.style.color = originalColor;
	}
	// Parse RGB string
	if (color.match(/^rgb/gi)) {
		rgb = color.match(/(\d+(\.\d+)?)/gi);
		// Deal with RGB percentages
		if (color.match(/%/gi)) {
			multiple = 2.55;
		}
		rgb[0] *= multiple;
		rgb[1] *= multiple;
		rgb[2] *= multiple;
		// Ad alpha channel if given
		if (rgb[3] !== undefined) {
			rgb[3] = parseFloat(rgb[3]);
		} else {
			rgb[3] = 1;
		}
	}
	return rgb;
}
878234
def hex_to_rgba(color):
    
    value = str(color).lstrip('#').strip()
    if len(value) == 6:
        rgb = [int(value[i:i + 2], 16) for i in (0, 2, 4)]
        rgba = np.append(rgb, 255).astype(np.uint8)
    else:
        raise ValueError('Only RGB supported')

    return rgba
1032557
public Color getColor(int x, int y) {
	    
		if (pixelData == null) {
			pixelData = texture.getTextureData();
		}
		
		
		int xo = (int) (textureOffsetX * texture.getTextureWidth());
		int yo = (int) (textureOffsetY * texture.getTextureHeight());
		
		if (textureWidth < 0) {
			x = xo - x;
		} else {
			x = xo + x;
		} 
		
		if (textureHeight < 0) {
			y = yo - y;
		} else {
			y = yo + y;
		}
		
		// Clamp to texture dimensions
		x %= texture.getTextureWidth();
		y %= texture.getTextureHeight();

		int offset = x + (y * texture.getTextureWidth());
		offset *= texture.hasAlpha() ? 4 : 3;
		
		if (texture.hasAlpha()) {
			return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]),
							 translate(pixelData[offset+2]),translate(pixelData[offset+3]));
		} else {
			return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]),
					 	     translate(pixelData[offset+2]));
		}
	}
7058
public final Color getColor(int x, int y) {
        int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
        int idx = x + y * width;

        return new RGBColor((pixels[idx] >> 16 & 0x000000ff) / 255.0,
                            (pixels[idx] >> 8  & 0x000000ff) / 255.0,
                            (pixels[idx]       & 0x000000ff) / 255.0,
                            (pixels[idx] >> 24)              / 255.0);
    }
1028839
function rgbaToColorMatrix(red, green, blue) {
  var alpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;

  var decToFloat = function decToFloat(value) {
    return Math.round(value / 255 * 10) / 10;
  };
  var redFloat = decToFloat(red);
  var greenFloat = decToFloat(green);
  var blueFloat = decToFloat(blue);
  var alphaFloat = decToFloat(alpha);
  return '0 0 0 0 ' + redFloat + ' 0 0 0 0 ' + greenFloat + ' 0 0 0 0 ' + blueFloat + ' 0 0 0 1 ' + alphaFloat;
}
584866
function(color, prc) {
		var num = parseInt(color, 16),
		    amt = Math.round(2.55 * prc),
		    R = (num >> 16) + amt,
		    G = (num >> 8 & 0x00FF) + amt,
		    B = (num & 0x0000FF) + amt;
		return (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
			(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
			(B < 255 ? B < 1 ? 0 : B : 255))
			.toString(16)
			.slice(1);
	}
36244
function (x0, y0, width, height, c)
    {
        _c = c || _c
        const data = _c.getImageData(x0, y0, width, height)
        const bits = data.data

        const pixels = []
        for (let y = 0; y < height; y += _scale)
        {
            for (let x = 0; x < width; x += _scale)
            {
                const index = x * 4 + y * width * 4
                if (bits[index + 3] === 0)
                {
                    pixels.push(null)
                }
                else
                {
                    const color = Color.rgbToHex(bits[index], bits[index + 1], bits[index + 2])
                    pixels.push(parseInt(color, 16))
                }
            }
        }
        return pixels
    }
807095
function adobe_rgb_to_lab (cr, cg, cb) {
	var p = adobe_rgb_to_xyz(cr, cg, cb);
	var x = p.x, y = p.y, z = p.z;

	var f = [];
	var r = [];

	r[0] = x / global_white.x;
	r[1] = y / global_white.y;
	r[2] = z / global_white.z;

	for (var i = 0; i < 3; i++) {
		if (r[i] > epsilon) {
			f[i] = Math.pow(r[i], 1 / 3);
		} else {
			f[i] = (kappa * r[i] + 16) / 116;
		}
	}
	var A = 500 * (f[0] - f[1]);
	var B = 200 * (f[1] - f[2]);

	return {
		A: A, B: B, y: y
	};
}
290504
function (color) {
            this.glArray[0] = me.Math.clamp(this.glArray[0] + color.glArray[0], 0, 1);
            this.glArray[1] = me.Math.clamp(this.glArray[1] + color.glArray[1], 0, 1);
            this.glArray[2] = me.Math.clamp(this.glArray[2] + color.glArray[2], 0, 1);
            this.glArray[3] = (this.glArray[3] + color.glArray[3]) / 2;

            return this;
        }
889598
function contrast(color) {
    const rgb = [parseInt(color.substring(1, 3), 16),
      parseInt(color.substring(3, 5), 16),
      parseInt(color.substring(5, 7), 16)];
    for (let i = 0; i < 3; i++) {
      rgb[i] = 255 - rgb[i];
    }
    return `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
  }