note 117690 added to function.imagefilledarc

From: Date: Thu, 23 Jul 2015 16:24:09 +0000
Subject: note 117690 added to function.imagefilledarc
Groups: php.notes 
Request: Send a blank email to php-notes+get-203163@lists.php.net to get a copy of this message
For everyone who will use imageellipse() with a border (imagesetthickness() not working correctly). This function simualtes the standard gd border. <?php function imageEllipseWithBorder($image, $centerX, $centerY, $width, $height, $color, $borderWidth) { // Calculate inner and outer strength of border $borderOuterStrength = (($borderWidth - 1) / 2); $borderInnerStrength = ((($borderWidth - 1) / 2) + 1); // Caculate x-/y-offset from 0/0 position to ellipse center $ellipseXOffset = $centerX - ($width / 2) - $borderOuterStrength; $ellipseYOffset = $centerY - ($height / 2) - $borderOuterStrength; // Create temp image for editing $tempImageWidth = $width + ($borderOuterStrength * 2) + 1; $tempImageHeight = $height + ($borderInnerStrength * 2) + 1; $tempImage = imagecreatetruecolor($tempImageWidth, $tempImageHeight); imagealphablending($tempImage, false); // Fill temp image with "transparent" color $transparent = imagecolorallocatealpha($tempImage, 255, 255, 255, 127); imagefill($tempImage, 0, 0, $transparent); // Draw outer ellipse (representing the border) imagefilledellipse( $tempImage, $centerX - $ellipseXOffset, $centerY - $ellipseYOffset, $width + $borderOuterStrength * 2, $height + $borderOuterStrength * 2, $color ); // Draw inner ellipse (transparent area) imagefilledellipse( $tempImage, $centerX - $ellipseXOffset, $centerY - $ellipseYOffset, $width - $borderInnerStrength * 2, $height - $borderInnerStrength * 2, $transparent ); // "Paste" ellipse (with transparent inner area) into image at original position imagealphablending($image, true); imagecopy( $image, $tempImage, $ellipseXOffset + ($borderWidth + 1) % 2, $ellipseYOffset + ($borderWidth + 1) % 2, 0, 0, $tempImageWidth, $tempImageHeight ); } ?> ---- Server IP: 213.172.110.13 Probable Submitter: 87.79.30.2 ---- Manual Page -- http://php.net/manual/en/function.imagefilledarc.php Edit -- https://master.php.net/note/edit/117690 Del: integrated -- https://master.php.net/note/delete/117690/integrated Del: useless -- https://master.php.net/note/delete/117690/useless Del: bad code -- https://master.php.net/note/delete/117690/bad+code Del: spam -- https://master.php.net/note/delete/117690/spam Del: non-english -- https://master.php.net/note/delete/117690/non-english Del: in docs -- https://master.php.net/note/delete/117690/in+docs Del: other reasons-- https://master.php.net/note/delete/117690 Reject -- https://master.php.net/note/reject/117690 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203163) next »