Hi all, I'm trying to make a script that will take a value (H) then blend from gray to black, but it only says Could not set BG when I run the script.
Code is listed below.
<?php
$im = imagecreate(10,$_GET['H'])
or die("Cannot Initialize new GD image stream");
$Start = 192;
$End = 0;
$Inc = (($End - $Start) / $_GET['H']);
// This next line's the problem.
$background_color = imagecolorallocate ($im, $Start, $Start, $Start)
or die ("Could not set BG");
$x1 = 0; //originating vertical X coordinate
$y1 = 0; //originating horizontal Y coordinate
$x2 = 1; //target vertical X coordinate
$y2 = 1; //target horizontal Y coordinate
for($a=1;$a<=$_GET['H'];$a++)
{
//move the line along one pixel
$x1 += 1;
$x2 += 1;
//change color variable
$Start += $Inc;
$NewColour = imagecolorallocate($im, $Start, $Start, $Start);
imageline($im,$x1,$y1,$x2,$y2,$NewColour);
}
header("Content-type:image/png");
ImagePng($im);
?>
Andrew.