note 45247 added to ref.image
| From: | andreoli dot carlo at libero dot it | Date: | Tue, 31 Aug 2004 10:17:46 +0000 |
| Subject: | note 45247 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75729@lists.php.net to get a copy of this message | ||
Here my compact gradient function (request few passage):
function imagecolorgradient($img,$x1,$y1,$height,$width,$colA,$colB) {
$varC1=($colA[1]-$colB[1])/$height;
$varC2=($colA[2]-$colB[2])/$height;
$varC3=($colA[3]-$colB[3])/$height;
for ($i=0;$i<=$height;$i++) {
$red=$colA[1]-floor($i*$varC1);
$green=$colA[2]-floor($i*$varC2);
$blue=$colA[3]-floor($i*$varC3);
$col= ImageColorAllocate($img,$red,$green,$blue);
ImageLine($img,$x1,$y1+$i,$x1+$width,$y1+$i,$col);
}
}
even more compact mode:
function imagecolorgradient($img,$x1,$y1,$height,$width,$colA,$colB) {
$varC1=($colA[1]-$colB[1])/$height;
$varC2=($colA[2]-$colB[2])/$height;
$varC3=($colA[3]-$colB[3])/$height;
for ($i=0;$i<=$height;$i++) {
$col=ImageColorAllocate($img,
$colA[1]-floor($i*$varC1),
$colA[2]-floor($i*$varC2),
$colA[3]-floor($i*$varC3));
ImageLine($img,$x1,$y1+$i,$x1+$width,$y1+$i,$col);
}
}
$img ist the image handle,
$x1 and $y1 are the start points,
$height is the gradient height, $width the width,
$colA and $colB are the first and second color ARRAYs.
----
Manual Page -- http://www.php.net/manual/en/ref.image.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45247
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45247&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45247&report=yes
Search -- http://master.php.net/manage/user-notes.php