This page shows a larger version of the grid image in the discussion on Pythagoras. The bigger image is 1000x500 pixels. The goal of this picture is to show that if you rotate a grid 45 degrees, the vertices of the rotated grid will not mesh up with those of the original grid. You can find more info on my blog (NOTE the php code for the image is below).
This is the PHP code.
/**
* Author: Kevin Delaney
* project http://y-intercept.com/rich/pythagoras.html
* date: 6/25/2008
*
*/
define('IMAGE_WIDTH',440);
define('IMAGE_HEIGHT',280);
define('SPACER', 18); // size of lines in the grid
$midX = floor(IMAGE_WIDTH /2);
$topY = 10;
$bottomY = IMAGE_HEIGHT - 10;
$offset = sqrt(SPACER*SPACER/2);
header ("Content-type: image/png");
$im = @imagecreatetruecolor(IMAGE_WIDTH, IMAGE_HEIGHT)
or die('Cannot Initialize new GD image stream');
$bg_color = imagecolorallocate($im, 220, 220, 255);
$line_color = imagecolorallocate($im, 40, 40, 40);
$slant_color = imagecolorallocate($im, 0, 20, 100);
imagefilledrectangle($im, 0, 0, IMAGE_WIDTH-1, IMAGE_HEIGHT-1, $bg_color);
// draw a grid
$cnt = 0;
// points in the slanted line.
$saX = $midX;
$saY = IMAGE_HEIGHT - 10;
$eaX = IMAGE_WIDTH - 10;
$eaY = $saY - ($eaX - $saX);
$hold = $eaY;
for ($i=IMAGE_HEIGHT - 10; $i > 10; $i -= SPACER) {
$diff = floor($cnt * $offset);
imageline($im, $midX,$i, IMAGE_WIDTH-10,$i, $line_color);
imageline($im, ($saX - $diff),($saY - $diff), ($eaX - $diff),($eaY - $diff), $slant_color);
if ($cnt++ > 40) die('you idiot 1');
}
// draw a grid
$cnt = 0;
// points in the slanted line.
$saX = $midX;
$saY = IMAGE_HEIGHT - 10;
$eaX = 10;
$eaY = $hold;
for ($i=$midX; $i < IMAGE_WIDTH-10; $i += SPACER) {
$diff = floor($cnt * $offset);
if ($cnt++ > 40) die('you idiot 2');
imageline($im, $i,10, $i,IMAGE_HEIGHT-10, $line_color);
imageline($im, ($saX + $diff),($saY - $diff), ($eaX + $diff),($eaY - $diff), $slant_color);
}
// clean up top margin.
imagefilledrectangle($im, 0, 0, IMAGE_WIDTH-1, 10, $bg_color);
imagepng($im);
imagedestroy($im);