note 66902 added to function.imageline
| From: | JamesLogsdon at osu1 dot php dot net | Date: | Wed, 31 May 2006 20:04:15 +0000 |
| Subject: | note 66902 added to function.imageline | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112676@lists.php.net to get a copy of this message | ||
I made a Gradient function that allows you to specify the starting and ending colors to be used.
Here it is:
For an example, you can go to http://www.girsbrain.org/imagegrad.php (source is
at http://www.girsbrain.org/imagegrad.php?source)
<?php
function imageGradient ( $img, $Data = array ( ) )
{
$StartX = !empty ( $Data['StartX'] ) ? $Data['StartX'] : 0;
$StartY = !empty ( $Data['StartY'] ) ? $Data['StartY'] : 0;
$Width = !empty ( $Data['Width'] ) ? $Data['Width'] : imagesx ( $img );
$Height = !empty ( $Data['Height'] ) ? $Data['Height'] : imagesy ( $img );
$Colors = is_array ( $Data['Colors'] ) ? $Data['Colors'] : array (
'Start' => array ( 'Red' => 0, 'Green' => 0, 'Blue'
=> 0 ), 'End' => array ( 'Red' => 255, 'Green' => 255,
'Blue' => 255 ) );
$EndY = $StartY + $Height;
$RedMove = $Colors['End']['Red'] -
$Colors['Start']['Red'];
$RedChange = $RedMove / $Height;
$GreenMove = $Colors['End']['Green'] -
$Colors['Start']['Green'];
$GreenChange = $GreenMove / $Height;
$BlueMove = $Colors['End']['Blue'] -
$Colors['Start']['Blue'];
$BlueChange = $BlueMove / $Height;
$CurRed = $Colors['Start']['Red'];
$CurGreen = $Colors['Start']['Green'];
$CurBlue = $Colors['Start']['Blue'];
for ( $CurY = $StartY; $CurY <= $EndY; $CurY++ )
{
$Color = imagecolorallocate ( $img, round ( $CurRed, 0 ), round ( $CurGreen, 0 ), round (
$CurBlue, 0 ) );
imageline ( $img, $StartX, $CurY, $Width, $CurY, $Color );
$CurRed += $RedChange;
$CurGreen += $GreenChange;
$CurBlue += $BlueChange;
}
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 69.15.171.66
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.imageline.php
Edit -- http://master.php.net/note/edit/66902
Del: integrated -- http://master.php.net/note/delete/66902/integrated
Del: useless -- http://master.php.net/note/delete/66902/useless
Del: bad code -- http://master.php.net/note/delete/66902/bad+code
Del: spam -- http://master.php.net/note/delete/66902/spam
Del: non-english -- http://master.php.net/note/delete/66902/non-english
Del: in docs -- http://master.php.net/note/delete/66902/in+docs
Del: other reasons-- http://master.php.net/note/delete/66902
Reject -- http://master.php.net/note/reject/66902
Search -- http://master.php.net/manage/user-notes.php