Voting

: zero minus zero?
(Example: nine)

The Note You're Voting On

nojer2 at yahoo dot com
24 years ago
Here's the function to draw rotated ellipses again. This time I've optimised it a bit, fixed the no-fill bug, and used a 'squishratio' rather than a 'radiusmodifier', to make the curves perfect, so ignore my previous version.

<?php
function rotatedellipse($im, $cx, $cy, $width, $height, $rotateangle, $colour, $filled=true) {
$step=2;
$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 = $centrey + (($ox * $sinangle) + ($oy * $cosangle));

if (
$nopreviouspoint) {
$px=$x;
$py=$y;
$nopreviouspoint=false;
}

if (
$filled) {
triangle($im, $cx, $cy, $cx+$px, $cy+$py, $cx+$x, $cy+$y, $colour);
triangle($im, $cx, $cy, $cx-$px, $cx-$py, $cx-$x, $cy-$y, $colour);
} else {
imageline($im, $cx+$px, $cy+$py, $cx+$x, $cy+$y, $colour);
imageline($im, $cx-$px, $cx-$py, $cx-$x, $cy-$y, $colour);
}
$px=$x;
$py=$y;
}
}

function
triangle($im, $x1,$y1, $x2,$y2, $x3,$y3, $colour) {
$coords = array($x1,$y1, $x2,$y2, $x3,$y3);
imagefilledpolygon($im, $coords, 3, $colour);
}
?>

<< Back to user notes page

To Top