function GetGradation($baseColor,$Rstep,$Gstep,$Bstep)

{

 $Rcode="";

 $Gcode="";

 $Bcode="";

 $retVal="";

 if(strpos($baseColor,"#") !== false)

 {

  if(strlen($baseColor) != 7)

   return "#ffffff";

  $Rcode = strtolower(substr($baseColor, 1, 2));

  $Gcode = strtolower(substr($baseColor, 3, 2));

  $Bcode = strtolower(substr($baseColor, 5, 2));

 }

 else

 {

  if(strlen($baseColor) != 6)

   return "#ffffff";

  $Rcode = strtolower(substr($baseColor, 0, 2));

  $Gcode = strtolower(substr($baseColor, 2, 2));

  $Bcode = strtolower(substr($baseColor, 4, 2));

 }

 $Rcode = hexdec($Rcode) + $Rstep;

 $Gcode = hexdec($Gcode) + $Gstep;

 $Bcode = hexdec($Bcode) + $Bstep;

 if($Rcode > 255) $Rcode = 255;

 if($Gcode > 255) $Gcode = 255;

 if($Bcode > 255) $Bcode = 255;

 if($Rcode < 0) $Rcode = 0;

 if($Gcode < 0) $Gcode = 0;

 if($Bcode < 0) $Bcode = 0;

 $Rcode = dechex($Rcode);

 $Gcode = dechex($Gcode);

 $Bcode = dechex($Bcode);

 if(strlen($Rcode) < 2)

  $Rcode ="0".$Rcode;

 if(strlen($Gcode) < 2)

  $Gcode ="0".$Gcode;

 if(strlen($Bcode) < 2)

  $Bcode ="0".$Bcode;

 $retVal = "#".$Rcode.$Gcode.$Bcode;

 return $retVal;

}

-----------------

사용법

  $bcolor = "#00ff00";

  for($k=0; $k<20;$k++)

  {

   $bcolor = GetGradation($bcolor,0,-10,0);

  }


+ Recent posts