note 87502 added to function.imagefilledellipse
| From: | Mark at osu1 dot php dot net | Date: | Mon, 08 Dec 2008 01:03:03 +0000 |
| Subject: | note 87502 added to function.imagefilledellipse | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147895@lists.php.net to get a copy of this message | ||
This draws an anti-aliased circle with an optional border. Call with <img
src="circle.php?r=50&fg=ff0000&bg=000000&bw=5&bc=ffff00"/> to draw a
filled circle with radius=50, foreground color=red, background color=black, border width=5, and
border color=yellow. Assumes register_globals is on, but you can fix that easily.
<?php
header('Content-type: image/png');
is_numeric($r) or $r = 8;
is_numeric($bw) or $bw = 0;
strlen($fg)==6 or $fg = 'e8e8e8';
strlen($bg)==6 or $bg = 'ffffff';
strlen($bc)==6 or $bc = '000000';
function hex2rgb($im,$hex) {
return imagecolorallocate($im,
hexdec(substr($hex,0,2)),
hexdec(substr($hex,2,2)),
hexdec(substr($hex,4,2))
);
}
$a = $r*2;
$b = $a*4;
$c = $b/2;
$d = $b;
$e = $d-($bw*8);
$im1 = imagecreatetruecolor($b,$b);
$im2 = imagecreatetruecolor($a,$a);
imagefill($im1,0,0,hex2rgb($im1,$bg));
if($bw) imagefilledellipse($im1,$c,$c,$d,$d,hex2rgb($im1,$bc));
imagefilledellipse($im1,$c,$c,$e,$e,hex2rgb($im1,$fg));
imagecopyresampled($im2,$im1,0,0,0,0,$a,$a,$b,$b);
imagepng($im2);
?>
----
Server IP: 216.235.15.211
Probable Submitter: 70.71.107.94
----
Manual Page -- http://www.php.net/manual/en/function.imagefilledellipse.php
Edit -- https://master.php.net/note/edit/87502
Del: integrated -- https://master.php.net/note/delete/87502/integrated
Del: useless -- https://master.php.net/note/delete/87502/useless
Del: bad code -- https://master.php.net/note/delete/87502/bad+code
Del: spam -- https://master.php.net/note/delete/87502/spam
Del: non-english -- https://master.php.net/note/delete/87502/non-english
Del: in docs -- https://master.php.net/note/delete/87502/in+docs
Del: other reasons-- https://master.php.net/note/delete/87502
Reject -- https://master.php.net/note/reject/87502
Search -- https://master.php.net/manage/user-notes.php