semi-transparent grid
Posted: Mon Nov 08, 2004 12:15 pm
I have a predrawn PNG map with a transparent background
I am trying to overlay a semi-transparent grid (size set will be variable)
I have it drawing the grid but cant get it to be semi-transparent
here is what I have so far
I am trying to overlay a semi-transparent grid (size set will be variable)
I have it drawing the grid but cant get it to be semi-transparent
here is what I have so far
Code: Select all
<?
Header( "Content-type: image/png");
$grid_alpha=75;
$grid_x = 10;
$grid_y = 10;
############
# Make Map #
############
$mapname=$_GET['map'];
//open map
$map=$loc.'/sources/map_images/'.$mapname.'.png';
$image = imagecreatefrompng($map);
$image_x = imagesx($image);
$image_y = imagesy($image);
//make grid
$grid_color = imagecolorallocatealpha($image, 0,0,255,$grid_alpha );
// draw the | lines
$x1=0;$x2=$grid_x;
$y1=0;$y2=$image_y;
while ($x1 < $image_x){
imageline( $image, $x1 , $y1 , $x2 , $y2 , $grid_color );
$x1=$x1+$grid_x;
$x2=$x2+$grid_x;
}
// draw the - lines
$x1=0;$x2=$image_x;
$y1=0;$y2=0;
while ($y1 < $image_y){
imageline ( $image , $x1 , $y1 , $x2 , $y2 , $grid_color );
$y1=$y1+$grid_y;
$y2=$y2+$grid_y;
}
ImagePNG($image);
/* cleanup memory */
ImageDestroy($image);
exit;
?>