note 93726 deleted from function.imagesetthickness by cmb

From: Date: Fri, 15 Jul 2016 17:26:07 +0000
Subject: note 93726 deleted from function.imagesetthickness by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206031@lists.php.net to get a copy of this message
Note Submitter: raffi dot semerciyan at gmail dot com ---- While recently "playing" with GD library for PHP I also encountered the problem of imagesetthickness not working with imageellipse. I think I found a good work around and wanted to share it with you: Instead of using <?php imageellipse($image, $pos_x, $pos_y, $elipse_w, $elipse_h, $color); ?> I successfully used: <?php imagearc($image, $pos_x, $pos_y, $elipse_w, $elipse_h, 0, 359.9, $color); ?> NOTE: Don't put exactly 360 instead of 359.9 because it seems that the implementation makes the test and uses imageellipse instead! Below is my Ellipse function that is sensitive to imagesetthickness function AND that creates a properly closed ellipse. <?php function myimageellipse($image, $x, $y, $rx, $ry, $color) { // We don't use imageellipse because the imagesetthickness function has // no effect. So the better workaround is to use imagearc. imagearc($image,$x,$y,$rx,$ry, 0,359,$color); // If we stop here, we don't have a properly closed ellipse. // Using imagefill at this point will flood outside the ellipse (actually arc). // We have to close the arc to make it a real ellipse. $cos359=0.99984769; $sin359=-0.01745240; $x1=round($x+$rx/2*$cos359); $y1=round($y+$ry/2*$sin359); $x2=round($x+$rx/2); $y2=round($y); // imageline is sensitive to imagesetthickness as well. imageline($image,$x1,$y1,$x2,$y2,$color); } ?>

« previous php.notes (#206031) next »