本文實例講述了php使用GD實現顏色漸變的方法。分享給大家供大家參考。具體實現方法如下:
1
2
3
4
5
6
7
8
9
10
11
|
<?php $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 ); ?> |
效果圖如下:
希望本文所述對大家的php程序設計有所幫助。