Created
May 19, 2015 19:45
-
-
Save anonymous/cc16aef419b28841ec68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$width = 1000; | |
$length = 100; | |
$leftR = 204; | |
$leftG = 119; | |
$leftB = 34; | |
$rightR = 1; | |
$rightG = 66; | |
$rightB = 37; | |
$x = array(); | |
$y = array(); | |
$p = imagecreatetruecolor($width,$length); | |
for ($i = 1; $i <= $width; $i++) { | |
array_push($x, ($i - 1)); | |
} | |
for ($i = 1; $i <= $length; $i++) { | |
array_push($y, ($i - 1)); | |
} | |
$rlr = $rightR - $leftR; | |
$rlb = $rightB - $leftB; | |
$rlg = $rightG - $leftG; | |
foreach ($x as $ex) { | |
$f = $ex / $width; | |
$r = $leftR + round($rlr * $f); | |
$g = $leftG + round($rlg * $f); | |
$b = $leftB + round($rlb * $f); | |
$c = imagecolorallocate($p, $r, $g, $b); | |
foreach ($y as $why) { | |
imagesetpixel($p, $ex, $why, $c); | |
} | |
} | |
header('Content-Type: image/png'); | |
imagepng($p); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment