Skip to content

Instantly share code, notes, and snippets.

@yoya
Created October 26, 2017 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoya/1252aee6b4dbb06ffa6ca693be00313e to your computer and use it in GitHub Desktop.
Save yoya/1252aee6b4dbb06ffa6ca693be00313e to your computer and use it in GitHub Desktop.
RYGB gradation Image Generator
<?php
$width = 255;
$height = 4;
$im = imagecreatetruecolor($width, $height);
for ($x = 0 ; $x < $width ; $x++) {
$r = imagecolorallocate($im, $x, 0, 0);
$y = imagecolorallocate($im, $x, $x, 0);
$g = imagecolorallocate($im, 0, $x, 0);
$b = imagecolorallocate($im, 0, 0, $x);
imagesetpixel($im, $x, 0, $r);
imagesetpixel($im, $x, 1, $y);
imagesetpixel($im, $x, 2, $g);
imagesetpixel($im, $x, 3, $b);
}
imagepng($im);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment