note 60643 added to function.imageantialias

From: Date: Thu, 12 Jan 2006 22:22:21 +0000
Subject: note 60643 added to function.imageantialias
Groups: php.notes 
Request: Send a blank email to php-notes+get-101663@lists.php.net to get a copy of this message
The only trick I found to draw an antialiased polygon AND keep it transparent (to use them as overlays in google maps for example)... make two images and merge them. Order of operations is important and the transparency color of the final image must be set after the merge: <? header("Content-type: image/png"); $values = array( 40, 50, // Point 1 (x, y) 20, 240, // Point 2 (x, y) 60, 60, // Point 3 (x, y) 240, 20, // Point 4 (x, y) 50, 40, // Point 5 (x, y) 10, 10 // Point 6 (x, y) ); $im = imagecreate(250, 250); $bg = imagecolorallocate($im, 255, 255, 255); $im2 = imagecreatetruecolor(250, 250); $bg2 = imagecolorallocate($im2, 255, 255, 255); imagefilledrectangle($im2,0,0,249,249,$bg2); imagecolortransparent($im2, $bg); imageantialias($im2, true); $c_red = imagecolorallocate($im2, 255, 0, 0); imagepolygon($im2, $values, 6, $c_red); imageantialias($im2, false); imagecopymerge($im, $im2,0,0,0,0,250,250,50); imagecolortransparent($im, $bg); $c_red_alpha = imagecolorallocatealpha($im, 255, 0, 0, 60); imagefilledpolygon($im, $values, 6, $c_red_alpha); imagepng($im); imagedestroy($im); imagedestroy($im2); ?> ---- Manual Page -- http://www.php.net/manual/en/function.imageantialias.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60643 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60643&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60643&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60643&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60643&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60643&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60643&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60643&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60643&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101663) next »