colors=$colors; if($numSteps!=NULL) $this->numSteps=$numSteps; $this->generate(); } public function generate(){ if(sizeof($this->colors)<2) return(FALSE); $steps=floor($this->numSteps/(sizeof($this->colors)-1)); $steps=ceil(($this->numSteps-sizeof($this->colors))/(sizeof($this->colors)-1))+1; for($i=0;$icolors)-1;$i++){ $this->fade($this->colors[$i],$this->colors[$i+1],$steps); } } private function fade($from,$to,$steps){ $from=$this->longHexToDec($from); if(sizeof($this->colorPath)==0) array_push($this->colorPath,$this->decToLongHex($from)); $to=$this->longHexToDec($to); for($i=1;$i<$steps;$i++){ $nColor=$this->setColorHue($from,$i/$steps,$to); if(sizeof($this->colorPath)<$this->numSteps) { array_push($this->colorPath,$this->decToLongHex($nColor)); array_push($this->colorRGB,$this->longHexToDec($this->decToLongHex($nColor))); } } if(sizeof($this->colorPath)<$this->numSteps) { array_push($this->colorPath,$this->decToLongHex($to)); array_push($this->colorRGB,$this->longHexToDec($this->decToLongHex($to))); } } private function longHexToDec($hex){ $r=hexdec(substr($hex,0,2)); $g=hexdec(substr($hex,2,2)); $b=hexdec(substr($hex,4,2)); return(array($r,$g,$b)); } private function decToLongHex($rgb){ $r = str_pad(dechex($rgb[0]), 2, '0', STR_PAD_LEFT); $g = str_pad(dechex($rgb[1]), 2, '0', STR_PAD_LEFT); $b = str_pad(dechex($rgb[2]), 2, '0', STR_PAD_LEFT); return($r . $g . $b); } private function setColorHue($originColor,$opacityPercent,$maskRGB) { $returnColor=array(); for($w=0;$w\n\t\n"; for($i=0;$icolorPath);$i++){ $string.="\t\tcolorPath[$i] . "\">" . $this->colorPath[$i] . "\n"; } $string.="\t\n\n"; return($string); } } ?>