note 106939 added to function.imageantialias
| From: | rudolf.malutki | Date: | Mon, 19 Dec 2011 21:15:16 +0000 |
| Subject: | note 106939 added to function.imageantialias | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185167@lists.php.net to get a copy of this message | ||
I little change function for transparent background.
function imagecircleaa($img, $cx, $cy, $r, $w, $s, $t, $color) // image, centerX, centerY, radius,
stroke width, aa width, tightness, color
{
$adj = $w + $s;
$sCol = imagecolorallocate($img, $color['r'], $color['g'],
$color['b']);
for($x = -$r - $adj; $x <= $r + $adj; $x++)
{
for($y = -$r - $adj; $y <= $r + $adj; $y++)
{
$d = sqrt($x * $x + $y * $y); // distance from pixel to center
$err = abs($d - $r); // absolute distance from pixel to circle edge
if($err <= $w / 2 + $s) // within the stroke width + smoothing radius
{
if($err <= $w / 2) // inside the stroke width so make it solid color
{
$aaCol = $sCol;
}
else // in the antialisaing region so make it a blended color
{
$err -= $w / 2; // adjust to the aliased part
$err = 1 - $err / $s; // adjust to between 0 and 1
$err = ($err - 0.5) * $t * 2; // adjust to -$t to +$t for tightness
$err = ($err / sqrt(1 + $err * $err) + 1) / 2; // sigmoid curve to smooth edges
$aaCol = imagecolorallocatealpha($img,$color['r'],
$color['g'], $color['b'],127-(127*$err));
}
imagesetpixel($img, $x + $cx, $y + $cy, $aaCol);
}
}
}
}
----
Server IP: 82.177.164.100
Probable Submitter: 81.219.54.77
----
Manual Page -- http://www.php.net/manual/en/function.imageantialias.php
Edit -- https://master.php.net/note/edit/106939
Del: integrated -- https://master.php.net/note/delete/106939/integrated
Del: useless -- https://master.php.net/note/delete/106939/useless
Del: bad code -- https://master.php.net/note/delete/106939/bad+code
Del: spam -- https://master.php.net/note/delete/106939/spam
Del: non-english -- https://master.php.net/note/delete/106939/non-english
Del: in docs -- https://master.php.net/note/delete/106939/in+docs
Del: other reasons-- https://master.php.net/note/delete/106939
Reject -- https://master.php.net/note/reject/106939
Search -- https://master.php.net/manage/user-notes.php