I've seen many people come up with ways to do a drop shadow behind a rectangle such as a picture. I haven't found one yet that was fast, PHP 4 complaint, and nice looking. Here is one I came up with last night. It takes an image, fills it with the background, and creates a blurred drop shadow at the specified coords using the colors and the distance offset specified. It looks great!!!
function blurRect(&$image, $distance, $rectX1, $rectY1, $rectX2, $rectY2, $shadowR, $shadowG, $shadowB, $backR, $backG, $backB) {
$potentialOverlap = ($distance * 2) * ($distance * 2);
$backgroundColor = imagecolorallocate($image, $backR, $backG, $backB);
$shadowColor = imagecolorallocate($image, $shadowR, $shadowG, $shadowB);
$imageWidth = imagesx($image);
$imageHeight = imagesy($image);
imageFilledRectangle($image, 0, 0, $imageWidth - 1, $imageHeight - 1, $backgroundColor);
imageFilledRectangle($image, $rectX1, $rectY1, $rectX2, $rectY2, $shadowColor);
for ( $pointX = $rectX1 - $distance; $pointX < $imageWidth; $pointX++ ) {
for ( $pointY = $rectY1 - $distance; $pointY < $imageHeight; $pointY++ ) {
if ( $pointX > $rectX1 + $distance &&
$pointX < $rectX2 - $distance &&
$pointY > $rectY1 + $distance &&
$pointY < $rectY2 - $distance ) {
$pointY = $rectY2 - $distance;
}
$boxX1 = $pointX - $distance;
$boxY1 = $pointY - $distance;
$boxX2 = $pointX + $distance;
$boxY2 = $pointY + $distance;
$xOverlap = max(0, min($boxX2, $rectX2) - max($boxX1, $rectX1));
$yOverlap = max(0, min($boxY2, $rectY2) - max($boxY1, $rectY1));
$totalOverlap = $xOverlap * $yOverlap;
$shadowPcnt = $totalOverlap / $potentialOverlap;
$backPcnt = 1.0 - $shadowPcnt;
$newR = $shadowR * $shadowPcnt + $backR * $backPcnt;
$newG = $shadowG * $shadowPcnt + $backG * $backPcnt;
$newB = $shadowB * $shadowPcnt + $backB * $backPcnt;
$newcol = imagecolorallocate($image, $newR, $newG, $newB);
imagesetpixel($image, $pointX, $pointY, $newcol);
}
}
}