Home > Article > Backend Development > PHP uses GD to implement color gradient example_PHP tutorial
This article describes how PHP uses GD to implement color gradients. Share it with everyone for your reference. The specific implementation method is as follows:
?
2 4 56 |
$im = imagecreate(255, 255);
$bg = imagecolorallocate($im, 0, 0, 0);
<🎜>for ($i = 255; $i >= 0; $i--) {
$color = imagecolorallocate($im, $i, $i, $i);
imagefilledrectangle($im, 0, $i, 255, 1, $color);
}
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
|