Fixed how angles are managed when drawing arcs: do it postscript-like

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9308 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2001-03-07 13:09:22 +00:00
parent bb5d3f6310
commit fe734480f2

View file

@ -844,15 +844,36 @@ static Class NSBezierPath_concrete_class = nil;
float startAngle_rad, endAngle_rad, diff;
NSPoint p0, p1, p2, p3;
while (startAngle < 0)
startAngle = startAngle + 360;
while (startAngle > 360)
startAngle = startAngle - 360;
/* We use the Postscript prescription for managing the angles and
drawing the arc. See the documentation for `arc' and `arcn' in
the Postscript Reference. */
while (endAngle < 0)
endAngle = endAngle + 360;
while (endAngle > 360)
endAngle = endAngle - 360;
if (clockwise)
{
/* This modification of the angles is the postscript
prescription. */
while (startAngle < endAngle)
endAngle -= 360;
/* This is used when we draw a clockwise quarter of
circumference. By adding diff at the starting angle of the
quarter, we get the ending angle. diff is negative because
we draw clockwise. */
diff = - PI / 2;
}
else
{
/* This modification of the angles is the postscript
prescription. */
while (endAngle < startAngle)
endAngle += 360;
/* This is used when we draw a counterclockwise quarter of
circumference. By adding diff at the starting angle of the
quarter, we get the ending angle. diff is positive because
we draw counterclockwise. */
diff = PI / 2;
}
/* Convert the angles to radians */
startAngle_rad = PI * startAngle / 180;
@ -863,23 +884,6 @@ static Class NSBezierPath_concrete_class = nil;
center.y + radius * sin (startAngle_rad));
[self moveToPoint: p0];
if (clockwise)
{
diff = -PI / 2;
if (startAngle_rad < endAngle_rad)
{
startAngle_rad += 2 * PI;
}
}
else
{
diff = PI / 2;
if (startAngle_rad > endAngle_rad)
{
startAngle_rad -= 2 * PI;
}
}
while ((clockwise) ? (startAngle_rad > endAngle_rad)
: (startAngle_rad < endAngle_rad))
{