note 13511 added to function.imagefilledellipse.php

From: Date: Tue, 19 Jun 2001 20:09:45 +0000
Subject: note 13511 added to function.imagefilledellipse.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-14461@lists.php.net to get a copy of this message
This draws a rotated ellipse. If you don't want filled ellipses, then you don't need the triangle function. function triangle($x1,$y1, $x2,$y2, $x3,$y3, $colour) { global $im; $coords = array($x1,$y1, $x2,$y2, $x3,$y3); imagefilledpolygon($im, $coords, 3, $colour); } function rotatedellipse($cx, $cy, $width, $height, $rotateangle, $colour, $filled=true) { global $im; $step=15; $cosangle=cos(deg2rad($rotateangle)); $sinangle=sin(deg2rad($rotateangle)); $squishratio = $height/$width; $nopreviouspoint = true; for ($angle=0; $angle<=(180+$step); $angle+=$step) { $ox = ($width * cos(deg2rad($angle))); $oy = ($width * sin(deg2rad($angle))) * $squishratio; $x = ($ox * $cosangle) - ($oy * $sinangle); $y = ($ox * $sinangle) + ($oy * $cosangle); if ($nopreviouspoint) { $px=$x; $py=$y; $nopreviouspoint=false; } if ($filled) { triangle($cx, $cy, $cx+$px, $cy+$py, $cx+$x, $cy+$y, $colour); triangle($cx, $cy, $cx-$px, $cy-$py, $cx-$x, $cy-$y, $colour); } else { imageline($im, $cx+$px, $cy+$py, $cx+$x, $cy+$y, $colour); imageline($im, $cx-$px, $cy-$py, $cx-$x, $cy-$y, $colour); } $px=$x; $py=$y; } } http://www.php.net/manual/en/function.imagefilledellipse.php

« previous php.notes (#14461) next »