note 97137 added to book.image
| From: | mailatecrossdotnl at osu1 dot php dot net | Date: | Sat, 03 Apr 2010 15:31:02 +0000 |
| Subject: | note 97137 added to book.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167674@lists.php.net to get a copy of this message | ||
hello there,
i made a function to create a gradient image.
description:
gradient(int image_width, int image_height,
int start_red, int start_green, int start_blue,
int end_red, int end_green, int end_blue,
bool vertical)
function:
<?php
function gradient($image_width, $image_height,$c1_r, $c1_g, $c1_b, $c2_r, $c2_g, $c2_b,
$vertical=false)
{
// first: lets type cast;
$image_width = (integer)$image_width;
$image_height = (integer)$image_height;
$c1_r = (integer)$c1_r;
$c1_g = (integer)$c1_g;
$c1_b = (integer)$c1_b;
$c2_r = (integer)$c2_r;
$c2_g = (integer)$c2_g;
$c2_b = (integer)$c2_b;
$vertical = (bool)$vertical;
// create a image
$image = imagecreatetruecolor($image_width, $image_height);
// make the gradient
for($i=0; $i<$image_height; $i++)
{
$color_r = floor($i * ($c2_r-$c1_r) / $image_height)+$c1_r;
$color_g = floor($i * ($c2_g-$c1_g) / $image_height)+$c1_g;
$color_b = floor($i * ($c2_b-$c1_b) / $image_height)+$c1_b;
$color = ImageColorAllocate($image, $color_r, $color_g, $color_b);
imageline($image, 0, $i, $image_width, $i, $color);
}
# Prints out all the figures and picture and frees memory
header('Content-type: image/png');
if($vertical){$image = imagerotate($image, 90, 0);}
ImagePNG($image);
imagedestroy($image);
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 84.81.68.86
----
Manual Page -- http://www.php.net/manual/en/book.image.php
Edit -- https://master.php.net/note/edit/97137
Del: integrated -- https://master.php.net/note/delete/97137/integrated
Del: useless -- https://master.php.net/note/delete/97137/useless
Del: bad code -- https://master.php.net/note/delete/97137/bad+code
Del: spam -- https://master.php.net/note/delete/97137/spam
Del: non-english -- https://master.php.net/note/delete/97137/non-english
Del: in docs -- https://master.php.net/note/delete/97137/in+docs
Del: other reasons-- https://master.php.net/note/delete/97137
Reject -- https://master.php.net/note/reject/97137
Search -- https://master.php.net/manage/user-notes.php