PHP/Graphics Image/imagefilledrectangle — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:37, 26 мая 2010
Changing colors with a loop
<?php
$image = imagecreate(400,300);
$gold = imagecolorallocate($image, 255, 240, 00);
$white = imagecolorallocate($image, 255, 255, 255);
$color = $white;
for ($i = 400, $j = 300; $i > 0; $i -= 4, $j -= 3) {
if ($color = = $white) {
$color = $gold;
} else {
$color = $white;
}
imagefilledrectangle($image, 400 - $i, 300 - $j, $i, $j, $color);
}
imagepng($image);
imagedestroy($image);
?>
Creating and Applying Different Shapes and Patterns
<?php
$animage = imagecreate (500, 500);
$white = imagecolorallocate ($animage, 255, 255, 255);
$black = imagecolorallocate ($animage, 0, 0, 0);
imagefilledrectangle ($animage, 0, 0, 500, 500, $black);
$blue = imagecolorallocate ($animage, 0, 0, 255);
$green = imagecolorallocate ($animage, 0, 255, 0);
$myvalues = array ("1","2","3","4","5","6");
$barwidth = (int) (500 / ((count ($myvalues) * 2)+ 1));
$barheightpernum = (int) (500 / 10);
imagefilledrectangle ($animage, 1, 300,498, $black);
imagepng ($animage);
header ("Content-type: image/png");
imagedestroy ($animage);
?>
Draw a rectangle
<?php
$image = imagecreate(400,300);
$white = imagecolorallocate($image, 255, 255, 255);
imagefilledrectangle($image, 10, 10, 390, 290, $white);
?>