summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-01-30 03:23:26 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-01-30 03:23:26 -0800
commit2fb5da215a7b286b71f8c4d0126c72a06e41935e (patch)
treecff5719050f031323d2c2b939f58748ebd250842 /includes
parentaed9779afb75e689263fe5867076e877ac6e4493 (diff)
downloadpathery-2fb5da215a7b286b71f8c4d0126c72a06e41935e.tar.xz
Dynamic resizing of mapThumbnail.
Diffstat (limited to 'includes')
-rw-r--r--includes/maps.php41
1 files changed, 36 insertions, 5 deletions
diff --git a/includes/maps.php b/includes/maps.php
index e5b6fdc..9ee6984 100644
--- a/includes/maps.php
+++ b/includes/maps.php
@@ -290,17 +290,48 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL)
function DisplayMapThumbnail($map, $link = false) {
$r = ''; //Prepare our return value:
- if ($link)
- $r .= "<table style='cursor:pointer' onclick='document.location.href=\"$link\"' class='map_thumbnail'>";
- else
- $r .= "<table class='map_thumbnail'>";
+
+ $tileWidth = 1 / $map->width;
+ $tileHeight = $goalSize / $map->height;
+
+ $sourceWidth = $map->width;
+ $sourceHeight = $map->height;
+
+ $targetWidth = 150;
+
+ $sourceRatio = $sourceWidth / $sourceHeight;
+
+ // if ( $sourceRatio < $targetRatio ) {
+ $scale = $sourceWidth / $targetWidth;
+ // } else {
+ // $scale = $sourceHeight / $targetHeight;
+ // }
+
+ $resizeWidth = (int)($sourceWidth / $scale);
+ $resizeHeight = (int)($sourceHeight / $scale);
+
+ //$height = $width / ($tileWidth / $tileHeight);
+ //$height = round($height);
+
+ $width = $resizeWidth.'px';
+ $height = $resizeHeight.'px';
+
+ //$height = '100px';
+ //if ($map-height > $map->width;)
+ $size = $size.'%';
+ //$size = '1.2px';
+ if ($link) {
+ $r .= "<table style='cursor:pointer' onclick='document.location.href=\"$link\"' class='map_thumbnail'>";
+ } else {
+ $r .= "<table style='width:$width;height:$height;' class='map_thumbnail'>";
+ }
for ($y = 0; $y < $map->height; $y++) { //Number of Rows
$r .= "<tr>";
for ($x = 0; $x < $map->width; $x++) { //Number of Columns
$value = $map->tiles[$y][$x][TileValue];
$type = $map->tiles[$y][$x][TileType];
- $r .= "<td class='$type$value'></td>";
+ $r .= "<td class='$type$value' style='width:$tileWidth%;'></td>";
}
$r .= "</tr>";
}