note 53654 added to function.imagecolorallocate

From: Date: Wed, 08 Jun 2005 13:38:58 +0000
Subject: note 53654 added to function.imagecolorallocate
Groups: php.notes 
Request: Send a blank email to php-notes+get-90114@lists.php.net to get a copy of this message
hsl to RGB (not yet optimized but it function) function hslToRgb ($h, $s, $l) { if ($h>240 || $h<0) return array(0,0,0); if ($s>240 || $s<0) return array(0,0,0); if ($l>240 || $l<0) return array(0,0,0); if ($h<=40) { $R=255; $G=(int)($h/40*256); $B=0; } elseif ($h>40 && $h<=80) { $R=(1-($h-40)/40)*256; $G=255; $B=0; } elseif ($h>80 && $h<=120) { $R=0; $G=255; $B=($h-80)/40*256; } elseif ($h>120 && $h<=160) { $R=0; $G=(1-($h-120)/40)*256; $B=255; } elseif ($h>160 && $h<=200) { $R=($h-160)/40*256; $G=0; $B=255; } elseif ($h>200) { $R=255; $G=0; $B=(1-($h-200)/40)*256; } $R=$R+(240-$s)/240*(128-$R); $G=$G+(240-$s)/240*(128-$G); $B=$B+(240-$s)/240*(128-$B); if ($l<120) { $R=($R/120)*$l; $G=($G/120)*$l; $B=($B/120)*$l; } else { $R=$l*((256-$R)/120)+2*$R-256; $G=$l*((256-$G)/120)+2*$G-256; $B=$l*((256-$B)/120)+2*$B-256; } if ($R<0) $R=0; if ($R>255) $R=255; if ($G<0) $G=0; if ($G>255) $G=255; if ($B<0) $B=0; if ($B>255) $B=255; return array((int)$R,(int)$G,(int)$B); } ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53654 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53654&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53654&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53654&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53654&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53654&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53654&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90114) next »