Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. function conversion($color, $param) {
  2. $r = substr($color, 1, 2);
  3. $g = substr($color, 3, 2);
  4. $b = substr($color, 5, 2);
  5. $r = hexdec($r);
  6. $g = hexdec($g);
  7. $b = hexdec($b);
  8. if ($newR >= $param) {$newR = $r - $param;} else if ($newR <= 255) {$newR = $r + $param;}
  9. if ($newG >= $param) {$newG = $g - $param;} else if ($newG <= 255) {$newG = $g + $param;}
  10. if ($newB >= $param) {$newB = $b - $param;} else if ($newB <= 255) {$newB = $b + $param;}
  11. $newR = dechex($newR);
  12. $newG = dechex($newG);
  13. $newB = dechex($newB);
  14. return "#" . $newR . $newG . $newB;
  15. }
  16.  
  17. echo conversion('#0073aa', 10); //resultado #a7db4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement