Created
July 6, 2017 08:31
-
-
Save Maden-maxi/262345ad1e93e489016af5e9adb3b1b6 to your computer and use it in GitHub Desktop.
Invert rgb color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function color_inverse_rgb($color){ | |
$rgb = trim( $color ); | |
if( strrpos($rgb, 'rgb') ){ | |
$rgb = str_replace('rgb(', '', $rgb); | |
$rgb = str_replace(')','',$rgb); | |
$rgb_array = explode(',',$rgb); | |
foreach ($rgb_array as $key => $rgb_color ){ | |
$rgb_array[$key] = 255 - (int)$rgb_color; | |
} | |
$rgb = implode(',',$rgb_array); | |
return 'rgb('.$rgb.')'; | |
}else{ | |
return $rgb; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment