<?php
$eol = "\r\n";
$img = imagecreatefrompng(__DIR__ . "/gradient-map-255.png");


$minU = 999;
$minV = 999;
$maxU = 0;
$maxV = 0;
$map = array();
for ($y = 0; $y < 48; $y++) {
	$map[$y] = array();
	for ($x = 0; $x < 64; $x++) {
		$u = 255 & imagecolorat($img, $x, $y);
		$v = 255 & imagecolorat($img, 64 + $x, $y);
		$map[$y][$x] = (object)array(
			'u' => $u,
			'v' => $v,
		);
		$maxU = max($maxU, $u);
		$maxV = max($maxV, $v);
		$minU = min($minU, $u);
		$minV = min($minV, $v);
	}
}
file_put_contents(__DIR__ . "/gradient-map.json", json_encode($map));
echo 'minU: ' . $minU . ', minV: ' . $minV . $eol;
echo 'maxU: ' . $maxU . ', maxV: ' . $maxV . $eol;


$handle = fopen ("php://stdin","r");
fgets($handle);
fclose($handle);


/*
gradient = 204 - для дырки
gradient = 66 - для круговой
*/
