I've made a file that returns an image of 1px multicoloured vertical lines.
The default height, width, colour and variance can be overridden with url variables.
The image can be called like this:
HTML Code:
<img src="linebar.php" />
With variables:
HTML Code:
<img src="linebar.php?w=300&h=100&c[]=123&c[]=43&c[]=204&v[]=19&v[]=65&v[]=37" />
When I use this file to create an image, the lines only go to a width of 255px, the rest of the image is filled with black (the background colour).
Is this the max number of times imageline can be called?
The file used for generating the image is here:
PHP Code:
<?php
#height
if(!($h=@$_GET["h"]))$h=50;
#width
if(!($w=@$_GET["w"]))$w=200;
#colour
if(!($c=@$_GET["c"]))$c=array(255,255,255);
#variance (array of {how much red varies, green's variance, ...} )
if(!($v=@$_GET["v"]))$v=array(255,255,255);
#get a random variance of a colour
function randomColour($colour,$variance){
#this is keeping the colour in acceptable margins (0 <= colour <= 255)
if($colour-$variance<0){
$colour+=rand(0,$variance);
}else if($colour+$variance>255){
$colour-=rand(0,$variance);
}else{
$colour+=rand(-$variance,$variance);
};
return $colour;
};
#tell browser to expect a jpeg
header('Content-Type: image/jpeg');
#make the base image
$image = imagecreate($w,$h);
#fill image with black
imagecolorallocate($image, 0, 0, 0);
#for each pixel in width
for($i=0;$i<$w;$i++){
#draw a vertical line with a randomed colour
imageline($image, $i, 0, $i, $h, imagecolorallocate($image, randomColour($c[0],$v[0]), randomColour($c[1],$v[1]), randomColour($c[2],$v[2])));
};
#output the jpeg
imagejpeg($image);
#destroy the image to free memory
imagedestroy($image);
?>
Bookmarks