欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php把一个颜色变深的函数

程序员文章站 2022-05-26 14:36:04
...

这个php函数可以把指定的颜色变得更深一些

  1. function ColorDarken($color, $dif=20){
  2. $color = str_replace('#', '', $color);
  3. if (strlen($color) != 6){ return '000000'; }
  4. $rgb = '';
  5. for ($x=0;$x $c = hexdec(substr($color,(2*$x),2)) - $dif;
  6. $c = ($c $rgb .= (strlen($c) }
  7. return '#'.$rgb;
  8. }
  9. //范例:
  10. for ($x=1; $x
  11. // Start color:
  12. $c = ColorDarken('#FF481D', ($x * 3));
  13. print "
    .
    \n";
  14. }
复制代码

php