A rectangle in GD is an image like the following example:
// Create a 55x30 image
$im = imagecreatetruecolor(55, 30);
$white = imagecolorallocate($im, 255, 255, 255);
// Draw a white rectangle
imagefilledrectangle($im, 4, 4, 50, 25, $white);
// Save the image
imagepng($im, 'imagefilledrectangle.png');
imagedestroy($im);
To make it interactive you can use CSS like placing the image as a background for a anchor tag:
<a href="#" id="myRectangle"></a>
then in CSS (assuming 2 images):
a#myRectangle{
background-image: url(imagefilledrectangle1.png);
}
a#myRectangle:hover{
background-image: url(imagefilledrectangle2.png);
}
You can do allot more with CSS or take a look at http://jquery.com/ to use JavaScript