note 117432 added to function.imagerectangle
| From: | stanislav dot eckert at vizson dot de | Date: | Wed, 10 Jun 2015 09:15:26 +0000 |
| Subject: | note 117432 added to function.imagerectangle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202799@lists.php.net to get a copy of this message | ||
Please pay attention if you want to draw pixel perfect rectangles: Since this function uses absolute
values for the second coordinate points (instead of width and height), you might face a logical
problem. PHP counts from 0. But a pixel at position 0,0 occupies already a 1x1 space. In the example
above you have the following line:
imagerectangle($canvas, 50, 50, 150, 150, $pink);
If you don't pay attention, you might thing that the difference between the two coordinates is
exactly 100 and assume that the drawn rectangle would have the dimension of 100 x 100 pixels too.
But it would be 101 x 101, because PHP counts from 0 and imagerectangle() uses absolute coordinates
for the second point too. A smaller example: A rectangle with coordinates 0,0 and 5,5 means
0,1,2,3,4,5 which are 6 pixels, not 5.
----
Server IP: 72.52.91.14
Probable Submitter: 85.177.89.127
----
Manual Page -- http://php.net/manual/en/function.imagerectangle.php
Edit -- https://master.php.net/note/edit/117432
Del: integrated -- https://master.php.net/note/delete/117432/integrated
Del: useless -- https://master.php.net/note/delete/117432/useless
Del: bad code -- https://master.php.net/note/delete/117432/bad+code
Del: spam -- https://master.php.net/note/delete/117432/spam
Del: non-english -- https://master.php.net/note/delete/117432/non-english
Del: in docs -- https://master.php.net/note/delete/117432/in+docs
Del: other reasons-- https://master.php.net/note/delete/117432
Reject -- https://master.php.net/note/reject/117432
Search -- https://master.php.net/manage/user-notes.php