1) $c = bijection($x%$lower, $y%$lower, $newPath, $lower); else $c = 0; return $lower*$lower*$i+$c; } function generateBijection() { $table = Array(); for($r=0; $r<27; ++$r) { for($g=0; $g<27; ++$g) { $a = bijection($r, $g, 2, 27); $table[$a] = Array($r, $g); } } return $table; } function generateRing($table, $radius, $blue, $SIZE, $im) { for($y=-$radius-$blue; $y<$radius+$blue; ++$y) { for($x=-$radius-$blue; $x<$radius+$blue; ++$x) { $thisRadius = $x*$x+$y*$y; if($thisRadius>=$radius*$radius && $thisRadius<=($radius+$blue)*($radius+$blue)) { $b = (sqrt($thisRadius)-$radius); if($x<0 && !$y) $a = 546; if($x>0 && !$y) $a = 182; if($y) { $a = -floor(729*atan($x/$y)/(2*3.14159)); if($y>0) { $a+=364; } elseif($x<0) $a+=728; } if($a<=364) $a2 = $a*2; else $a2 = 1457 - $a*2; list($r, $g) = $table[$a2]; $cr = floor($r*9.48); $cg = floor($g*9.48); $cb = floor($b*255/$blue); $color = imagecolorallocate($im, $cr, $cg, $cb); imagesetpixel($im, $x+floor($SIZE/2), $y+floor($SIZE/2), $color); } } } } function generateBelt($table, $SIZE, $im) { for($y=0; $y<$SIZE; ++$y) { for($x=0; $x<$SIZE*$SIZE; ++$x) { list($r, $g) = $table[$x]; $color = imagecolorallocate($im, $r*9.48, $g*9.48, $y*255/($SIZE-1)); imagesetpixel($im, $x, $y, $color); } } } function drawBelt($showHeaders) { $SIZE = 27; $im = imagecreatetruecolor($SIZE*$SIZE, $SIZE); $white = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, $SIZE*$SIZE, $SIZE, $white); $table = generateBijection(); generateBelt($table, $SIZE, $im); if($showHeaders) header('Content-type: image/png'); imagepng($im); } function drawRing($showHeaders) { $SIZE = 524; $im = imagecreatetruecolor($SIZE, $SIZE); $white = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, $SIZE, $SIZE, $white); $table = generateBijection(); generateRing($table, 129, 129, $SIZE, $im); if($showHeaders) header('Content-type: image/png'); imagepng($im); } // drawRing($true); drawBelt($true); ?>