mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 07:10:59 +00:00
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:
parent
bb5d3f6310
commit
fe734480f2
1 changed files with 41 additions and 37 deletions
|
@ -844,15 +844,36 @@ static Class NSBezierPath_concrete_class = nil;
|
||||||
float startAngle_rad, endAngle_rad, diff;
|
float startAngle_rad, endAngle_rad, diff;
|
||||||
NSPoint p0, p1, p2, p3;
|
NSPoint p0, p1, p2, p3;
|
||||||
|
|
||||||
while (startAngle < 0)
|
/* We use the Postscript prescription for managing the angles and
|
||||||
startAngle = startAngle + 360;
|
drawing the arc. See the documentation for `arc' and `arcn' in
|
||||||
while (startAngle > 360)
|
the Postscript Reference. */
|
||||||
startAngle = startAngle - 360;
|
|
||||||
|
|
||||||
while (endAngle < 0)
|
if (clockwise)
|
||||||
endAngle = endAngle + 360;
|
{
|
||||||
while (endAngle > 360)
|
/* This modification of the angles is the postscript
|
||||||
endAngle = endAngle - 360;
|
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 */
|
/* Convert the angles to radians */
|
||||||
startAngle_rad = PI * startAngle / 180;
|
startAngle_rad = PI * startAngle / 180;
|
||||||
|
@ -863,23 +884,6 @@ static Class NSBezierPath_concrete_class = nil;
|
||||||
center.y + radius * sin (startAngle_rad));
|
center.y + radius * sin (startAngle_rad));
|
||||||
[self moveToPoint: p0];
|
[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)
|
while ((clockwise) ? (startAngle_rad > endAngle_rad)
|
||||||
: (startAngle_rad < endAngle_rad))
|
: (startAngle_rad < endAngle_rad))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue