/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* set drop shadow options */ /* offset of drop shadow from top left */ /* number of steps from black to background color /* define("DS_STEPS", 10); /* distance between steps */ /* define the background color */ /* create a new canvas. New canvas dimensions should be larger than the original's */ $width = $o_width + DS_OFFSET; $height = $o_height + DS_OFFSET; /* determine the offset between colors */ $step_offset = array("r" => ($background["r"] / DS_STEPS), "g" => ($background["g"] / DS_STEPS), "b" => ($background["b"] / DS_STEPS)); /* calculate and allocate the needed colors */ $current_color = $background; for ($i = 0; $i <= DS_STEPS; $i++) { $colors[$i] = imagecolorallocate($image, round($current_color["r"]), round($current_color["g"]), round($current_color["b"])); $current_color["r"] -= $step_offset["r"]; $current_color["g"] -= $step_offset["g"]; $current_color["b"] -= $step_offset["b"]; } /* floodfill the canvas with the background color */ /* draw overlapping rectangles to create a drop shadow effect */ $width -= DS_SPREAD; $height -= DS_SPREAD; } /* overlay the original image on top of the drop shadow */ /* output the image */ /* clean up the image resources */ } ?>
URL: http://www.codewalkers.com/c/a/Miscellaneous/Adding-Drop-Shadows-with-PHP/
Comments
