Calculates the Delta E (CIE1976) of two colors.
163826
def delta_e_cie1976(color1, color2):
    
    color1_vector = _get_lab_color1_vector(color1)
    color2_matrix = _get_lab_color2_matrix(color2)
    delta_e = color_diff_matrix.delta_e_cie1976(color1_vector, color2_matrix)[0]
    return numpy.asscalar(delta_e)
81036
def F(self, **kwargs):
        '''
        
        '''
        Eg = self.Eg_Gamma_0(**kwargs)
        Delta_SO = self.Delta_SO(**kwargs)
        Ep = self.Ep(**kwargs)
        meff = self.meff_e_Gamma_0(**kwargs)
        return (1./meff-1-(Ep*(Eg+2.*Delta_SO/3.))/(Eg*(Eg+Delta_SO)))/2
237216
def calculate_color_temperature(r, g, b):
    """"""
    # 1. Map RGB values to their XYZ counterparts.
    # Based on 6500K fluorescent, 3000K fluorescent
    # and 60W incandescent values for a wide range.
    # Note: Y = Illuminance or lux
    X = (-0.14282 * r) + (1.54924 * g) + (-0.95641 * b)
    Y = (-0.32466 * r) + (1.57837 * g) + (-0.73191 * b)
    Z = (-0.68202 * r) + (0.77073 * g) + ( 0.56332 * b)
    # Check for divide by 0 (total darkness) and return None.
    if (X + Y + Z) == 0:
        return None
    # 2. Calculate the chromaticity co-ordinates
    xc = (X) / (X + Y + Z)
    yc = (Y) / (X + Y + Z)
    # Check for divide by 0 again and return None.
    if (0.1858 - yc) == 0:
        return None
    # 3. Use McCamy's formula to determine the CCT
    n = (xc - 0.3320) / (0.1858 - yc)
    # Calculate the final CCT
    cct = (449.0 * (n ** 3.0)) + (3525.0 *(n ** 2.0)) + (6823.3 * n) + 5520.33
    return int(cct)
1307483
def delta(self,local=False):
        
        (s,e) = self.get(local)
        return e-s
296107
def binomialInterval(n, k, alpha = 0.68):
    
    e = float(k)/n
    delta_e = 1/float(n) * np.sqrt(e * (1 - e) * float(n)) * alpha/0.68
    return e, [e - delta_e, e + delta_e]
399662
function(color1, color2, factor) {
		if (arguments.length < 3) { factor = 0.5; }
		var hsl1 = this.rgb2hsl(color1);
		var hsl2 = this.rgb2hsl(color2);
		for (var i=0;i<3;i++) {
			hsl1[i] += factor*(hsl2[i]-hsl1[i]);
		}
		return this.hsl2rgb(hsl1);
	}
412188
private double doubleValue2Colors( double left, double right ) {
        return rgba( doubleValue( red( left ), red( right ) ), //
                        doubleValue( green( left ), green( right ) ), //
                        doubleValue( blue( left ), blue( right ) ), 1 );
    }
936599
protected function ciede2000DeltaE($firstLabColor, $secondLabColor)
	    {
	        list($L1, $a1, $b1) = $firstLabColor;
	        list($L2, $a2, $b2) = $secondLabColor;

	        $C1 = sqrt(pow($a1, 2) + pow($b1, 2));
	        $C2 = sqrt(pow($a2, 2) + pow($b2, 2));
	        $Cb = ($C1 + $C2) / 2;

	        $G = .5 * (1 - sqrt(pow($Cb, 7) / (pow($Cb, 7) + pow(25, 7))));

	        $a1p = (1 + $G) * $a1;
	        $a2p = (1 + $G) * $a2;

	        $C1p = sqrt(pow($a1p, 2) + pow($b1, 2));
	        $C2p = sqrt(pow($a2p, 2) + pow($b2, 2));

	        $h1p = $a1p == 0 && $b1 == 0 ? 0 : atan2($b1, $a1p);
	        $h2p = $a2p == 0 && $b2 == 0 ? 0 : atan2($b2, $a2p);

	        $LpDelta = $L2 - $L1;
	        $CpDelta = $C2p - $C1p;

	        if ($C1p * $C2p == 0) {
	            $hpDelta = 0;
	        } elseif (abs($h2p - $h1p) <= 180) {
	            $hpDelta = $h2p - $h1p;
	        } elseif ($h2p - $h1p > 180) {
	            $hpDelta = $h2p - $h1p - 360;
	        } else {
	            $hpDelta = $h2p - $h1p + 360;
	        }

	        $HpDelta = 2 * sqrt($C1p * $C2p) * sin($hpDelta / 2);

	        $Lbp = ($L1 + $L2) / 2;
	        $Cbp = ($C1p + $C2p) / 2;

	        if ($C1p * $C2p == 0) {
	            $hbp = $h1p + $h2p;
	        } elseif (abs($h1p - $h2p) <= 180) {
	            $hbp = ($h1p + $h2p) / 2;
	        } elseif ($h1p + $h2p < 360) {
	            $hbp = ($h1p + $h2p + 360) / 2;
	        } else {
	            $hbp = ($h1p + $h2p - 360) / 2;
	        }

	        $T = 1 - .17 * cos($hbp - 30) + .24 * cos(2 * $hbp) + .32 * cos(3 * $hbp + 6) - .2 * cos(4 * $hbp - 63);

	        $sigmaDelta = 30 * exp(-pow(($hbp - 275) / 25, 2));

	        $Rc = 2 * sqrt(pow($Cbp, 7) / (pow($Cbp, 7) + pow(25, 7)));

	        $Sl = 1 + ((.015 * pow($Lbp - 50, 2)) / sqrt(20 + pow($Lbp - 50, 2)));
	        $Sc = 1 + .045 * $Cbp;
	        $Sh = 1 + .015 * $Cbp * $T;

	        $Rt = -sin(2 * $sigmaDelta) * $Rc;

	        return sqrt(
	            pow($LpDelta / $Sl, 2) +
	            pow($CpDelta / $Sc, 2) +
	            pow($HpDelta / $Sh, 2) +
	            $Rt * ($CpDelta / $Sc) * ($HpDelta / $Sh)
	        );
	    }
464772
def similarity( color1, color2, ignore_lightness: false )
      l1, a1, b1 = *rgb2lab(color1.to_rgb)
      l2, a2, b2 = *rgb2lab(color2.to_rgb)
      Math.sqrt( (ignore_lightness ? 0 : (l1-l2)**2) + (a1-a2)**2 + (b1-b2)**2 )
    end
412002
function(e) {
        var delta = this.delta;
        this.delta = 0;
        
        if (delta) {
            e.xy = this.map.events.getMousePosition(e);
            if (delta < 0) {
                this.callback("down",
                    [e, this.cumulative ? Math.max(-this.maxDelta, delta) : -1]);
            } else {
                this.callback("up",
                    [e, this.cumulative ? Math.min(this.maxDelta, delta) : 1]);
            }
        }
    }
297963
def get_and_subtract(self, delta):
        '''
        
        '''
        with self._reference.get_lock():
            oldval = self._reference.value
            self._reference.value -= delta
            return oldval
1350901
def _mix(color1, color2, weight=0.5, **kwargs):
    
    weight = float(weight)
    c1 = color1.value
    c2 = color2.value
    p = 0.0 if weight < 0 else 1.0 if weight > 1 else weight
    w = p * 2 - 1
    a = c1[3] - c2[3]

    w1 = ((w if (w * a == -1) else (w + a) / (1 + w * a)) + 1) / 2.0
    w2 = 1 - w1
    q = [w1, w1, w1, p]
    r = [w2, w2, w2, 1 - p]
    return ColorValue([c1[i] * q[i] + c2[i] * r[i] for i in range(4)])
52398
function(color1, color2, amount) {
    var p = amount / 100.0;
    var w = p * 2 - 1;
    var hsl1 = this.toHSL(color1);
    var hsl2 = this.toHSL(color2);
    var a = hsl1.a - hsl2.a;

    var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
    var w2 = 1 - w1;

    var rgb = [
        color1[0] * w1 + color2[0] * w2,
        color1[1] * w1 + color2[1] * w2,
        color1[2] * w1 + color2[2] * w2
    ];

    var alpha = color1[3] * p + color2[3] * (1 - p);
    rgb[3] = alpha;
    return rgb;
  }
876676
private static double colorBlending( double color1, double color2, int op ) {
        long argb1 = Double.doubleToRawLongBits( color1 );
        long r1 = ((argb1 >> 32) & 0xFFFF);
        long g1 = ((argb1 >> 16) & 0xFFFF);
        long b1 = ((argb1) & 0xFFFF);

        long argb2 = Double.doubleToRawLongBits( color2 );
        long r2 = ((argb2 >> 32) & 0xFFFF);
        long g2 = ((argb2 >> 16) & 0xFFFF);
        long b2 = ((argb2) & 0xFFFF);

        r1 = colorBlendingDigit( r1, r2, op );
        g1 = colorBlendingDigit( g1, g2, op );
        b1 = colorBlendingDigit( b1, b2, op );
        argb1 = r1 << 32 | g1 << 16 | b1;

        return Double.longBitsToDouble( argb1 );
    }
190872
def euclidian other_color
      # TODO: different depths
      r  = (self.r.to_i - other_color.r.to_i)**2
      r += (self.g.to_i - other_color.g.to_i)**2
      r += (self.b.to_i - other_color.b.to_i)**2
      Math.sqrt r
    end
625975
def _get_deltas(event):
        """"""
        delta_x = round(event.deltaX())
        delta_y = round(event.deltaY())
        delta_z = round(event.deltaZ())
        return delta_x, delta_y, delta_z
326652
def delta_e_cie1994(color1, color2, K_L=1, K_C=1, K_H=1, K_1=0.045, K_2=0.015):
    
    color1_vector = _get_lab_color1_vector(color1)
    color2_matrix = _get_lab_color2_matrix(color2)
    delta_e = color_diff_matrix.delta_e_cie1994(
        color1_vector, color2_matrix, K_L=K_L, K_C=K_C, K_H=K_H, K_1=K_1, K_2=K_2)[0]
    return numpy.asscalar(delta_e)