lib/class-kirki-color.php
public static function color_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
		$color_1 = self::sanitize_hex( $color_1, false );
		$color_2 = self::sanitize_hex( $color_2, false );
		$color_1_rgb = self::get_rgb( $color_1 );
		$color_2_rgb = self::get_rgb( $color_2 );
		$r_diff = max( $color_1_rgb[0], $color_2_rgb[0] ) - min( $color_1_rgb[0], $color_2_rgb[0] );
		$g_diff = max( $color_1_rgb[1], $color_2_rgb[1] ) - min( $color_1_rgb[1], $color_2_rgb[1] );
		$b_diff = max( $color_1_rgb[2], $color_2_rgb[2] ) - min( $color_1_rgb[2], $color_2_rgb[2] );
		$color_diff = $r_diff + $g_diff + $b_diff;
		return $color_diff;
	}
public static function color_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
		$color_1 = self::sanitize_hex( $color_1, false );
		$color_2 = self::sanitize_hex( $color_2, false );
		$color_1_rgb = self::get_rgb( $color_1 );
		$color_2_rgb = self::get_rgb( $color_2 );
		$r_diff = max( $color_1_rgb[0], $color_2_rgb[0] ) - min( $color_1_rgb[0], $color_2_rgb[0] );
		$g_diff = max( $color_1_rgb[1], $color_2_rgb[1] ) - min( $color_1_rgb[1], $color_2_rgb[1] );
		$b_diff = max( $color_1_rgb[2], $color_2_rgb[2] ) - min( $color_1_rgb[2], $color_2_rgb[2] );
		$color_diff = $r_diff + $g_diff + $b_diff;
		return $color_diff;
	}
public static function color_difference ( $ color_1 = '#ffffff' , $ color_2 = '#000000' ) { $ color_1 = self :: sanitize_hex ( $ color_1 , false ) ; $ color_2 = self :: sanitize_hex ( $ color_2 , false ) ; $ color_1_rgb = self :: get_rgb ( $ color_1 ) ; $ color_2_rgb = self :: get_rgb ( $ color_2 ) ; $ r_diff = max ( $ color_1_rgb [ 0 ] , $ color_2_rgb [ 0 ] ) - min ( $ color_1_rgb [ 0 ] , $ color_2_rgb [ 0 ] ) ; $ g_diff = max ( $ color_1_rgb [ 1 ] , $ color_2_rgb [ 1 ] ) - min ( $ color_1_rgb [ 1 ] , $ color_2_rgb [ 1 ] ) ; $ b_diff = max ( $ color_1_rgb [ 2 ] , $ color_2_rgb [ 2 ] ) - min ( $ color_1_rgb [ 2 ] , $ color_2_rgb [ 2 ] ) ; $ color_diff = $ r_diff + $ g_diff + $ b_diff ; return $ color_diff ; }
This is a very simple algorithm that works by summing up the differences between the three color components red, green and blue.
A value higher than 500 is recommended for good readability.

@static
@access public
@param string $color_1 The 1st color.
@param string $color_2 The 2nd color.
@return string
This is a very simple algorithm that works by summing up the differences between the three color components red green and blue . A value higher than 500 is recommended for good readability .