note 119174 added to function.imagesetthickness
| From: | gmail dot com at mspreij | Date: | Fri, 15 Apr 2016 13:11:03 +0000 |
| Subject: | note 119174 added to function.imagesetthickness | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205236@lists.php.net to get a copy of this message | ||
As you can see in the example image, the left and right sides are 1 px wider than they should be,
this is the case for every width > 1.
Wrote this function to fix that bit.. probably not a drop-in replacement though. It draws a
rectangle *around* the given coordinates, for any width line.
<?php
// draw a $width-wide line AROUND the given coordinates, keeping in mind 0,0,1,1 yields a 2Ã2
square
function imagelinerectangle($img, $x1, $y1, $x2, $y2, $color, $width=1) {
imagefilledrectangle($img, $x1-$width, $y1-$width, $x2+$width, $y1-1, $color);
imagefilledrectangle($img, $x2+1, $y1-$width, $x2+$width, $y2+$width, $color);
imagefilledrectangle($img, $x1-$width, $y2+1, $x2+$width, $y2+$width, $color);
imagefilledrectangle($img, $x1-$width, $y1-$width, $x1-1, $y2+$width, $color);
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 213.126.10.250
----
Manual Page -- http://php.net/manual/en/function.imagesetthickness.php
Edit -- https://master.php.net/note/edit/119174
Del: integrated -- https://master.php.net/note/delete/119174/integrated
Del: useless -- https://master.php.net/note/delete/119174/useless
Del: bad code -- https://master.php.net/note/delete/119174/bad+code
Del: spam -- https://master.php.net/note/delete/119174/spam
Del: non-english -- https://master.php.net/note/delete/119174/non-english
Del: in docs -- https://master.php.net/note/delete/119174/in+docs
Del: other reasons-- https://master.php.net/note/delete/119174
Reject -- https://master.php.net/note/reject/119174
Search -- https://master.php.net/manage/user-notes.php