|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-01-30 23:54 UTC] jumo at gmx dot de
[2006-01-31 00:11 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 13:00:01 2025 UTC |
Description: ------------ I want to draw many squares on a PNG image, wich have changing color. after some correct drawed there is only one color used. Reproduce code: --------------- <?php $bigsize = 500; $colours = array( 'FF0000' , '00FF00' ); header("Content-type: image/png"); $im = imagecreate( $bigsize * 2 , 50 ); for( $j = 0; $j < $bigsize ; $j++ ) { $k = $j % count( $colours ); $r = hexdec( substr( $colours[ $k ] , 0 , 2 ) ); $g = hexdec( substr( $colours[ $k ] , 2 , 2 ) ); $b = hexdec( substr( $colours[ $k ] , 4 , 2 ) ); $fill = imagecolorallocate($im, $r , $g , $b ); imagefilledrectangle( $im , 2*$j , 0 , 2*$j+1 , 50 , $fill ); } imagepng($im); imagedestroy($im); ?> Expected result: ---------------- a bar with red and green vertical stripes wich have changing colors. Actual result: -------------- the right half of the bar is green.