 |
imagerectangle (PHP 3, PHP 4, PHP 5) imagerectangle -- 画一个矩形 说明bool imagerectangle ( resource image, int x1, int y1, int x2, int y2, int col )
imagerectangle() 用
col 颜色在
image 图像中画一个矩形,其左上角坐标为
x1, y1,右下角坐标为 x2, y2。图像的左上角坐标为
0, 0。
administrador(ensaimada)sphoera(punt)com
04-May-2006 10:28
<?php
// With this function you will draw rounded corners rectangles with transparent colors.
// Empty (not filled) figures are allowed too!!
function draw_roundrectangle($img, $x1, $y1, $x2, $y2, $radius, $color,$filled=1) {
if ($filled==1){
imagefilledrectangle($img, $x1+$radius, $y1, $x2-$radius, $y2, $color);
imagefilledrectangle($img, $x1, $y1+$radius, $x1+$radius-1, $y2-$radius, $color);
imagefilledrectangle($img, $x2-$radius+1, $y1+$radius, $x2, $y2-$radius, $color);
imagefilledarc($img,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $color, IMG_ARC_PIE);
imagefilledarc($img,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $color, IMG_ARC_PIE);
imagefilledarc($img,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $color, IMG_ARC_PIE);
imagefilledarc($img,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $color, IMG_ARC_PIE);
}else{
imageline($img, $x1+$radius, $y1, $x2-$radius, $y1, $color);
imageline($img, $x1+$radius, $y2, $x2-$radius, $y2, $color);
imageline($img, $x1, $y1+$radius, $x1, $y2-$radius, $color);
imageline($img, $x2, $y1+$radius, $x2, $y2-$radius, $color);
imagearc($img,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $color);
imagearc($img,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $color);
imagearc($img,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $color);
imagearc($img,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $color);
}
}
?>
More functions at http://www.sphoera.com
carl at pappenheim dot net
20-Feb-2006 07:02
Oh I don't know. He was on the right track..
<?php
$rows = 5;
$cols = 11;
$eachx = 12;
$eachy = 18;
$max = array($cols*$eachx, $rows*$eachy);
$im = imagecreatetruecolor($max[0]+1,$max[1]+1);
$white = imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$white);
$black = imagecolorallocate($im,50,50,50);
for($x=$max[0]/2;$x>=0;$x-=$eachx) {
imagerectangle($im, ($max[0]/2)+$x,0, ($max[0]/2)-$x,$max[1], $black);
}
for($y=$max[1]/2;$y>=0;$y-=$eachy) {
imagerectangle($im, 0,($max[1]/2)+$y, $max[0],($max[1]/2)-$y, $black);
}
header("Content-type: image/jpeg");
imagejpeg($im,'',80);
imagedestroy($im);
?>
matt at bargolf dot net
31-Jan-2006 06:25
Lets not do it Mr Benson's way OK!
I'm sure if I had to draw a 10x10 grid on paper I wouldn't do it by drawing 100 individual squares, redrawing nearly half of the lines twice.
I'd probably do it by drawing 11 vertical lines and 11 horizontal lines.
function ImageGrid2(&$im,$startx,$starty,$width,$height,$xcols,$yrows,&$color) {
$endy = $starty + $height * $yrows;
for ( $x=0; $x <= $xcols; $x++ ) {
$x1 = $startx + $width * $x;
imageline ( $im, $x1, $starty, $x1, $endy, $color );
}
$endx = $startx + $width * $xcols;
for ( $y=0; $y <= $yrows; $y++ ) {
$y1 = $starty + $height * $y;
imageline ( $im, $startx, $y1, $endx, $y1, $color );
}
}
eustaquiorangel at yahoo dot com
18-Dec-2002 01:21
If you want an empty rectangle, I mean, just the borders, fill it first with the ImageFilledRectangle function with the background color and then draw it with this function.
jbenson at technologist dot com
28-Nov-2000 02:41
For those wanting a function to draw a grid I've created one. I hope this is the right place to post it.
function ImageGrid(&$im,$startx,$starty,$width,$height,$xcols,$yrows,&$color) {
for ( $x=0; $x < $xcols; $x++ ) {
for ( $y=0; $y < $yrows; $y++ ) {
$x1 = $startx + ($width * $x);
$x2 = $startx + ($width * ($x+1));
$y1 = $starty + ($height * $y);
$y2 = $starty + ($height * ($y+1));
ImageRectangle($im, $x1, $y1, $x2, $y2, $color);
}
}
} // end function ImageGrid
|  |