<?
include("functions.php");
session_start();
header( "Content-type: image/png" );

$image = imagecreatefrompng("resources/map/img.png");
$hexaRed = imagecreatefrompng("resources/small-territories/hexaRed2.png");
$hexaWidth = getHexaWidth();
$hexaHeight = getHexaHeight();

$imageSize = 11;

$done = false;

$path = $_SESSION['tmpPath'][$_GET['i']]["path"];

foreach($path as $node) {
    $baseX = getTerritoryX($node) * $hexaWidth * 3/4;
    $baseY = getTerritoryY($node) * $hexaHeight;

    if (getTerritoryX($node) % 2 == 1) {
        $baseY += $hexaHeight / 2;
    }

    imagecopy($image, $hexaRed, $baseX - $imageSize/2 + $hexaWidth/2, $baseY - $imageSize/2 + $hexaHeight/2, 0, 0, $imageSize, $imageSize);
}


imagepng(imagescale($image, 600));

?>