PHP Gradient Generator
April 28, 2011| Tweet |
Simply enter the starting color in Hex (000000 through FFFFFF) and ending color, then the count of graduations you'd like to use.
Download Original
function gradient($startcol,$endcol,$graduations=10) { $graduations--; for($i=0;$i<=$graduations;$i++) { //Make HTML Happy $HexCol[] = "$HexR$HexG$HexB"; } RETURN $HexCol; }
Function Use
Download Original
<?PHP $Gradient = gradient("000000","123456",10); foreach ($Gradient as $color) { echo "<div style='color:#$color;margin:0px;padding:0px;'>■■■■ Hexadecimal Color: #$color ■■■■</div>"; }
$Gradient above returns the following array:Array
(
[0] => 000000
[1] => 020509
[2] => 040b13
[3] => 06111c
[4] => 081726
[5] => 0a1c2f
[6] => 0c2239
[7] => 0e2842
[8] => 102e4c
[9] => 123456
)
End output of this function results in this:

No comments yet! Be the first!

Facebook
LinkedIn