38 if ( empty( $value ) ) {
41 $value = trim( $value );
43 if ( preg_match(
"/^[0-9ABCDEFabcdef\#]+$/i", $value ) ) {
44 $value = str_replace(
'#',
'', $value );
45 $l = strlen( $value ) == 3 ? 1 : ( strlen( $value ) == 6 ? 2 : false );
49 $out[
'red'] = hexdec( substr( $value, 0, 1 * $l ) );
50 $out[
'green'] = hexdec( substr( $value, 1 * $l, 1 * $l ) );
51 $out[
'blue'] = hexdec( substr( $value, 2 * $l, 1 * $l ) );
58 elseif ( preg_match(
"/^[0-9]+(,| |.)+[0-9]+(,| |.)+[0-9]+$/i", $value ) ) {
59 $spr = str_replace( array(
',',
' ',
'.' ),
':', $value );
60 $e = explode(
":", $spr );
61 if ( count( $e ) != 3 ) {
65 for ( $i = 0; $i < 3; $i++ ) {
66 $e[$i] = dechex( ( $e[$i] <= 0 ) ? 0 : ( ( $e[$i] >= 255 ) ? 255 : $e[$i] ) );
69 for ( $i = 0; $i < 3; $i++ ) {
70 $out .= ( ( strlen( $e[$i] ) < 2 ) ?
'0' :
'' ) . $e[$i];
72 $out = strtoupper( $out );
95 $rgb = self::rgb2hex( $hex );
96 if ( empty( $rgb ) ) {
100 foreach ( $rgb as $key => $val ) {
102 $rgb[$key] = ( $rgb[$key] < 0 ) ? 0 : $rgb[$key];
104 $hex = self::rgb2hex( implode(
',', $rgb ) );