Login   Register  
PHP Classes
elePHPant
Icontem

File: fadebar.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Soulreaper  >  fadebar.php  >  fadebar.php  >  Download  
File: fadebar.php
Role: ???
Content type: text/plain
Description: fading bar file to use in image tag
Class: fadebar.php
Author: By
Last change:
Date: 13 years ago
Size: 1,261 bytes
 

Contents

Class file image Download
<?php
header("Content-type image/jpeg");

$height = 5;

// colors to fade
$red_start   = 150;
$red_end     = 255;

$green_start = 0;
$green_end   = 255;

$blue_start  = 0;
$blue_end    = 255;


$im = @ImageCreate($width,$height) or die ("no image possible");


function dif ($start,$end)
{
	if ($start >= $end)
		$dif = $start - $end;
	else
		$dif = $end - $start;
		
	return $dif;
}


function draw($start,$end,$pos,$step_width)
{
	if ($start > $end)	
		$color = $start - $step_width * $pos;
	else
		$color = $start + $step_width * $pos;
		
	return $color;
}	


// difference between start and end
$dif_red = dif($red_start,$red_end);
$dif_green = dif($green_start,$green_end);
$dif_blue = dif($blue_start,$blue_end);

// width of one color step
$step_red = $dif_red / $width;
$step_green = $dif_green / $width;
$step_blue = $dif_blue / $width;


$height = $height-1;

for ($pos=0; $pos<=$width; $pos++)
{
	$color = ImageColorAllocate($im,draw($red_start,$red_end,$pos,$step_red),
						   			draw($green_start,$green_end,$pos,$step_green),
						   			draw($blue_start,$blue_end,$pos,$step_blue));	
	
	imageline($im,$pos,"0",$pos,$height,$color);
	
}

imagejpeg($im);
imagedestroy($im);


?>