Mercurial > hg > batmud > gmap2
changeset 173:fa0a8bb7fcfd gmap2
Removed.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 11 Mar 2014 21:22:59 +0200 |
parents | c62f0cf2bf16 |
children | d68af0d5b924 |
files | overlay.php |
diffstat | 1 files changed, 0 insertions(+), 129 deletions(-) [+] |
line wrap: on
line diff
--- a/overlay.php Tue Mar 11 21:17:52 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -<?php -$cachepath = "cache/"; -$tilesize = 256; - -$patchfont = "./tools/lucon.ttf"; -$patchsize = array(); -$patchsize[ 8] = 7; -$patchsize[16] = 13; -$patchsize[32] = 26; - -$labelfont = "./tools/avenir.ttf"; -$labelsize = array(); -$labelsize[ 4] = 8; -$labelsize[ 8] = 10; -$labelsize[16] = 12; -$labelsize[32] = 14; - -// Get parameters -$vzoom = isset($_GET["zoom"]) ? intval($_GET["zoom"]) : 0; -$zoom = pow(2, $vzoom - 6); -$xc = isset($_GET["x"]) ? intval($_GET["x"]) : 0; -$yc = isset($_GET["y"]) ? intval($_GET["y"]) : 0; - - -// Check if we have a cached version -$cachefile = $cachepath."bl_".$zoom."_".$xc."_".$yc.".png"; -$mtime = @filemtime($cachefile); -if ($mtime !== FALSE || time() - $mtime < 7*24*60*60) -{ - header("Content-type: image/png"); - readfile($cachefile); - exit; -} - - -// Initialize image object -$im = @imagecreate($tilesize, $tilesize); - -$c_trans = imagecolorallocate($im, 0,32,0); -imagecolortransparent($im, $c_trans); -$c_alpha = imagecolorallocatealpha($im, 0,0,0,150); -$c_black = imagecolorallocate($im, 0,0,0); -$c_white = imagecolorallocate($im, 255,255,255); - -imagefilledrectangle($im, 0,0, $tilesize,$tilesize, $c_trans); - - -function chkcoords($xoffs, $yoffs) -{ - global $xorig, $yorig, $tilesize; - - return - $xoffs > $xorig - $tilesize && $xoffs < $xorig + ($tilesize*2) && - $yoffs > $yorig - $tilesize && $yoffs < $yorig + ($tilesize*2); -} - - -$xorig = $xc * $tilesize; -$yorig = $yc * $tilesize; -$flag = FALSE; - -if ($zoom >= 4) -{ - -$file = fopen("overlay.txt", "r"); -while ($data = fgetcsv($file, 160, ",")) -{ - $xoffs = $data[0] * $zoom; - $yoffs = $data[1] * $zoom; - $char = $data[2]; - - if ($zoom >= 8 && chkcoords($xoffs, $yoffs)) - { - $px = $xoffs - $xorig; - $py = $yoffs - $yorig; - - imagefilledrectangle($im, $px, $py, $px+$zoom-1, $py+$zoom-1, $c_black); - imagettftext($im, $patchsize[$zoom], 0, - $px+$patchsize[$zoom]/4, - $py+$patchsize[$zoom], $c_white, $patchfont, $char); - - //imagechar($im,$patchsize[$zoom],$px,$py,$char,$c_white); - $flag = TRUE; - } -} -fclose($file); - - -$file = fopen("overlaylabels.txt", "r"); -while ($data = fgetcsv($file, 160, ",")) -{ - $xoffs = $data[0] * $zoom; - $yoffs = $data[1] * $zoom; - $text = $data[2]; - - if ($zoom >= 4 && chkcoords($xoffs, $yoffs)) - { - $px = $xoffs - $xorig; - $py = $yoffs - $yorig; - - $box = imagettfbbox($labelsize[$zoom], 0, $labelfont, $text); - imagefilledrectangle($im, - $px+$box[6]-2, - $py+$box[7]+2, - $px+$box[2]+2, - $py+$box[3]+6, - $c_alpha); - - imagettftext($im,$labelsize[$zoom],0,$px,$py+5, $c_white, $labelfont, $text); - $flag = TRUE; - } -} -fclose($file); - -} // zoom check - -// If tile block is dirty, store to a file -if ($flag) -{ - @imagepng($im, $cachefile); - @chmod($cachefile, 0644); -} - - -// Send out as PNG -header("Content-type: image/png"); -imagepng($im); -imagedestroy($im); -?>