Code :
- <?php
- header('Content-type: image/png');
- $rayon = $_GET['r'];
- $diam = $rayon * 2 + 1;
- $hexH = 33;
- $hexW = 67;
- $hexHR = 7;
- $hexWR = 10;
- $margeSup = 20;
- $marges = 5;
- $height = $diam * $hexH + $hexHR;
- $heightR = $height + $margeSup + $marges;
- $width = $diam * $hexW + $hexWR;
- $widthR = $width + $marges + $marges;
- $im = imagecreatetruecolor($widthR, $heightR);
- $noir = imagecolorallocate($im, 0, 0, 0);
- imagefill( $im, 0, 0, $noir);
- imagecolortransparent($im, $noir);
- imagealphablending($im, true);
- $hexa = imagecreatefrompng("montagne.png" );
- $noir = imagecolorallocate($hexa, 0, 0, 0);
- imagecolortransparent($hexa, $noir);
- //imagealphablending($hexa, true);
- $x0 = $rayon * $hexH;
- $y0 = $rayon * $hexW;
- $yi = $rayon;
- while ($yi >= -$rayon)
- {
- $xi = -$rayon;
- while ($xi <= $rayon)
- {
- if(($xi<=0 and $yi<=0) or ($xi>=0 and $yi>=0) or ($rayon >= abs($yi)+abs($xi)))
- {
- $im = drawHex($xi, $yi, $im, $hexa, $x0, $y0);
- }
- $xi = $xi + 1;
- }
- $yi = $yi - 1;
- }
- imagedestroy($hexa);
- imagepng($im);
- imagedestroy($im);
- function drawHex($x ,$y , $img, $hex, $x0, $y0)
- {
-
- $x0 = $x0 + $x * 9;
- $y0 = $y0 + $x * 67;
- $x0 = $x0 - $y * 33;
- $y0 = $y0 - $y * 18;
- imagecopymerge($img, $hex, 0, 0, -$y0, -$x0, 700, 500, 100);
- return $img;
- }
- ?>
|