note 81741 added to function.imagesetthickness

From: Date: Wed, 12 Mar 2008 00:28:52 +0000
Subject: note 81741 added to function.imagesetthickness
Groups: php.notes 
Request: Send a blank email to php-notes+get-136956@lists.php.net to get a copy of this message
The way that imagesetthickness works with imagerectangle() is pretty strange. <?php imagesetthickness(1); imagerectangle($im, 10, 10, 50, 50, $red); ?> This will draw a 41x41 square (because gd need the bottom right pixel, inclusive. 50 should get replaced by 49). This will "work" like: <?php imageline($im, 10, 10, 10, 50, $red); imageline($im, 10, 10, 50, 10, $red); imageline($im, 50, 10, 50, 50, $red); imageline($im, 10, 50, 50, 50, $red); ?> The second example: <?php imagesetthickness(2); imagerectangle($im, 10, 10, 50, 50, $red); ?> This will draw a 43x43 square because the border (thickness) is set to 2. *however* this is not a "regular" border of 2 pixels around the 41x41 original square! On the left and right, there will be a thickness of 3, while there we be a thickness of 2. If you take the imageline example, but set the thickness before to 2, this will *almost* do the trick: the left most pixel of the square will not be drawn. To conclude: 1) do not forget that (width, height) of drawn rectangle is (x2-x1+1, y2-y1+1) 2) thickness is bad implemented (or at least, the behavior i s not documented) on rectangle, as the left/right thickness is not the wanted one. 3) 4*imageline() should do the trick, but after "patching" the top left pixel. ---- Server IP: 195.221.21.36 Probable Submitter: 89.80.203.136 ---- Manual Page -- http://www.php.net/manual/en/function.imagesetthickness.php Edit -- https://master.php.net/note/edit/81741 Del: integrated -- https://master.php.net/note/delete/81741/integrated Del: useless -- https://master.php.net/note/delete/81741/useless Del: bad code -- https://master.php.net/note/delete/81741/bad+code Del: spam -- https://master.php.net/note/delete/81741/spam Del: non-english -- https://master.php.net/note/delete/81741/non-english Del: in docs -- https://master.php.net/note/delete/81741/in+docs Del: other reasons-- https://master.php.net/note/delete/81741 Reject -- https://master.php.net/note/reject/81741 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136956) next »