Skip to content

Instantly share code, notes, and snippets.

@Maden-maxi
Created July 6, 2017 08:31
Show Gist options
  • Save Maden-maxi/262345ad1e93e489016af5e9adb3b1b6 to your computer and use it in GitHub Desktop.
Save Maden-maxi/262345ad1e93e489016af5e9adb3b1b6 to your computer and use it in GitHub Desktop.
Invert rgb color
<?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