note 98192 added to function.imageline
[email protected] Mon, 31 May 2010 14:55:54 -0700
Newsgroups
php.notes
Message-ID
<[email protected] >
Function drawing of a line by a brush uses midpoint circle algorithm..., if dullness I agree to remove :)))
<?php
//function drawLine(resource$image,int $x0,int $y0,int $x1,int $y1,int $lineWidth,int $color)
function drawLine($image,$x0, $y0,$x1, $y1,$radius,$color)
{
$f = 1 - $radius;
$ddF_x= 1;
$ddF_y = -2 * $radius;
$x= 0;
$y = $radius;
imageline($image,$x0, $y0 + $radius,$x1, $y1 + $radius,$color);
imageline($image,$x0, $y0 - $radius,$x1, $y1 - $radius,$color);
imageline($image,$x0 + $radius, $y0,$x1 + $radius, $y1,$color);
imageline($image,$x0 - $radius, $y0,$x1 - $radius, $y1,$color);
while($x< $y)
{
if($f >= 0)
{
$y--;
$ddF_y += 2;
$f += $ddF_y;
}
$x++;
$ddF_x+= 2;
$f += $ddF_x;
imageline($image,$x0 + $x, $y0 + $y,$x1 + $x, $y1+ $y,$color);
imageline($image,$x0 - $x, $y0 + $y,$x1 - $x, $y1 + $y,$color);
imageline($image,$x0 + $x, $y0 - $y,$x1 + $x, $y1 - $y,$color);
imageline($image,$x0 - $x, $y0 - $y,$x1 - $x, $y1 - $y,$color);
imageline($image,$x0 + $y, $y0 + $x,$x1 + $y, $y1 + $x,$color);
imageline($image,$x0 - $y, $y0 + $x,$x1 - $y, $y1 + $x,$color);
imageline($image,$x0 + $y, $y0 - $x,$x1 + $y, $y1 - $x,$color);
imageline($image,$x0 - $y, $y0 - $x,$x1 - $y, $y1 - $x,$color);
}
}
header ('Content-type: image/png');
$img = imagecreatetruecolor(600,600);
$col = imagecolorallocate($img,0,255,252);
//use the function
rasterCircle($img,50, 50,540,540,40,$col);
imagepng($img);
imagedestroy($img);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 90.191.203.99
----
Manual Page -- http://www.php.net/manual/en/function.imageline.php
Edit -- https://master.php.net/note/edit/98192
Del: integrated -- https://master.php.net/note/delete/98192/integrated
Del: useless -- https://master.php.net/note/delete/98192/useless
Del: bad code -- https://master.php.net/note/delete/98192/bad+code
Del: spam -- https://master.php.net/note/delete/98192/spam
Del: non-english -- https://master.php.net/note/delete/98192/non-english
Del: in docs -- https://master.php.net/note/delete/98192/in+docs
Del: other reasons-- https://master.php.net/note/delete/98192
Reject -- https://master.php.net/note/reject/98192
Search -- https://master.php.net/manage/user-notes.php