php - Graphic design program not working -
i read graphic design extensions in php , trying create square different colors. example.
here program:
<?php $color = array(0 => array('35', '3b', '1a'), 1 => array('7e', 'a6', '29'), 2 => array('d9', 'c9', '9a'), 3 => array('d9', '30', '30'), 4 => array('73', '07', '10'), 5 => array('d9', '62', 'c6') ); $image = imagecreate(200,200); $maxsize = 200; $currentcolor = 0; $yellow = imagecolorallocate($image, 0xff, 0xff, 0x00); for($i = 0; $i <= 200; $i += 10) { if($currentcolor == 6) { $currentcolor = 0; } $red = "0x".$color[$currentcolor][0]; $green = "0x".$color[$currentcolor][1]; $blue = "0x".$color[$currentcolor][2]; $red = (int)$red; $green = (int)$green; $blue = (int)$blue; $rescolor = imagecolorallocate($image, $red, $green, $blue); imagefilledrectangle($image, $i, $i, $maxsize -= 10, $maxsize -= 10, $rescolor); $currentcolor++; } header("content-type: image/png"); imagepng($image); ?>
however, code produces black square. how can make square multicolored?
these 2 arguments not want:
imagefilledrectangle($image, $i, $i, $maxsize -= 10, $maxsize -= 10, $rescolor);' ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
this code functioning as:
$maxsize = $maxsize - 10; $foo = $maxsize; $maxsize = $maxsize - 10; $bar = $maxsize; imagefilledrectangle($image, $i, $i, $foo, $bar, $rescolor);
Comments
Post a Comment