Edit report at https://bugs.php.net/bug.php?id=53156&edit=1
ID: 53156 Updated by: fel...@php.net Reported by: ljb9832 at pobox dot com Summary: imagerectangle problem with point ordering -Status: Open +Status: Assigned Type: Bug Package: GD related Operating System: Linux PHP Version: 5.3.3 -Assigned To: +Assigned To: pajoye Block user comment: N Private report: N New Comment: What do you think about, Pierre? Previous Comments: ------------------------------------------------------------------------ [2010-10-25 21:50:51] ljb9832 at pobox dot com Description: ------------ The documentation says imagerectangle() requires the upper left point first, then the lower right, whereas imagefilledrectangle() accepts the points in any order. In fact, imagerectangle() does work with all 4 possible orderings of the points, but only when drawing with unit thickness. When drawing rectangles with thickness > 1, only 2 of the 4 cases work. Before marking this as "working as documented" (which it is), please consider that there seems to be incorrect logic in gdImageRectangle() when handling the points. It tests for y2<y1 and if so it swaps both X and Y. It should test and swap X and Y independently, same as gdImageFilledRectangle does. So it seems to already be trying to avoid this requirement for point order, but it doesn't quite work in all cases. Test script: --------------- <?php $img = imagecreate(400, 800); $bgnd = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); $green = imagecolorallocate($img, 0, 255, 0); imagesetthickness($img, 4); imagestring($img, 4, 20, 140, 'Order: upper left, lower right', $black); imagerectangle($img, 20, 20, 120, 120, $black); imagefilledrectangle($img, 15, 15, 25, 25, $green); // Mark start point imagestring($img, 4, 20, 340, 'Order: lower left, upper right', $black); imagerectangle($img, 20, 320, 120, 220, $black); imagefilledrectangle($img, 15, 315, 25, 325, $green); // Mark start point imagestring($img, 4, 20, 540, 'Order: Upper right, lower left', $black); imagerectangle($img, 120, 420, 20, 520, $black); imagefilledrectangle($img, 115, 415, 125, 425, $green); // Mark start point imagestring($img, 4, 20, 740, 'Order: Lower right, upper left', $black); imagerectangle($img, 120, 720, 20, 620, $black); imagefilledrectangle($img, 115, 715, 125, 725, $green); // Mark start point imagepng($img); Expected result: ---------------- 4 rectangles, drawn with thick lines. Actual result: -------------- 2 rectangles, and two sets of parallel lines. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=53156&edit=1