Home  >  Article  >  Backend Development  >  PHP uses GD to implement color gradient example_PHP tutorial

PHP uses GD to implement color gradient example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:52:122291browse

An example of how PHP uses GD to implement color gradients

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:

 ?

1

2

3

4

5

6

7

8

9

10

11

$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);

?>

1

2
3

4

5

6

8 9 10 11

$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); ?>
The rendering is as follows: I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/1009818.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1009818.htmlTechArticlePHP uses GD to implement color gradient examples. 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: ? 1 2 3 4 5 6 7 8 9 1...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn