Advertisemen
Let's start by drawing a line first.
<?php
$width = 500;
$height = 200;
$img = ImageCreateTrueColor($width, $height);
$background_color = 0xFFFFFF; // white
ImageFilledRectangle($img, 0, 0, $width - 1,
$height - 1, $background_color);
imagesetthickness($img, 5);
$x1 = $y1 = 10 ;
$x2 = $y2 = $height - 1;
$color = 0xCCCCCC; // gray
ImageLine($img, $x1, $y1, $x2, $y2, $color);
header('Content-type: image/png');
ImagePNG($img);
ImageDestroy($img);
?>
There are nothing much to explain here because most of them are pretty self explanatory.
ImageFilledRectange creates a rectangle with height of 199px (200-1) and width of 499px (500-1) then we create line using ImageLine function, line starts at (x1, y1) = 10 and ends at (x2, y2) = 499.
This should print out the image like this :
Replace ImageLine($img, $x1, $y1, $x2, $y2, $color) with :
ImageRectangle($img, $x1, $y1, $x2, $y2, $color); if you want to create rectangle.
Thanks....
ImageFilledRectange creates a rectangle with height of 199px (200-1) and width of 499px (500-1) then we create line using ImageLine function, line starts at (x1, y1) = 10 and ends at (x2, y2) = 499.
This should print out the image like this :
Replace ImageLine($img, $x1, $y1, $x2, $y2, $color) with :
ImageRectangle($img, $x1, $y1, $x2, $y2, $color); if you want to create rectangle.
ImageFilledRectangle($img, $x1, $y1, $x2, $y2, $color); if you want to create filled rectangle.
ImagePolygon($img, $points, count($points)/2, $color); if you want to draw a polygon.
$points = array($x1, $y1, $x2, $y2, $x3, $y3);
ImageFilledPolygon($img, $points, count($points)/2, $color); if you want to draw filled polygon.
ImagePolygon($img, $points, count($points)/2, $color); if you want to draw a polygon.
$points = array($x1, $y1, $x2, $y2, $x3, $y3);
ImageFilledPolygon($img, $points, count($points)/2, $color); if you want to draw filled polygon.
Advertisemen
Tidak ada komentar:
Posting Komentar