note 123443 added to function.imageopenpolygon

From: Date: Sun, 16 Dec 2018 11:56:06 +0000
Subject: note 123443 added to function.imageopenpolygon
Groups: php.notes 
Request: Send a blank email to php-notes+get-209912@lists.php.net to get a copy of this message
In case you want to use an open polygon but are stuck with a PHP version prior to 7.2, a solution may be to 'backplot' your array to its original start. Say you have an array of pixels (below seperated by commas) <?php $arr = array(); for ($i = 0; $i < count($pixels); $i++) { $pixel = explode(',', $pixels[$i]); if (($pixel[0] > 0) && ($pixel[1] > 0)) { $arr[] = $pixel[0]; $arr[] = $pixel[1]; } } imagepolygon($im, $arr, (count($arr) / 2), $otcolor); ?> you can replace this by something like <?php $arr = array(); for ($i = 0; $i < count($pixels); $i++) { $pixel = explode(',', $pixels[$i]); $arr[] = $pixel[0]; $arr[] = $pixel[1]; } // imageopenpolygon($im, $arr, (count($arr) / 2), $otcolor) is not possible, so... for ($i = (count($pixels)-1); $i >= 0; $i--) { $pixel = explode(',', $pixels[$i]); $arr[] = $pixel[0]; $arr[] = $pixel[1]; } imagepolygon($im, $arr, (count($arr) / 2), $otcolor); ?> ---- Server IP: 208.43.231.9 Probable Submitter: 86.88.75.152 ---- Manual Page -- http://php.net/manual/en/function.imageopenpolygon.php Edit -- https://master.php.net/note/edit/123443 Del: integrated -- https://master.php.net/note/delete/123443/integrated Del: useless -- https://master.php.net/note/delete/123443/useless Del: bad code -- https://master.php.net/note/delete/123443/bad+code Del: spam -- https://master.php.net/note/delete/123443/spam Del: non-english -- https://master.php.net/note/delete/123443/non-english Del: in docs -- https://master.php.net/note/delete/123443/in+docs Del: other reasons-- https://master.php.net/note/delete/123443 Reject -- https://master.php.net/note/reject/123443 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209912) next »