[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix: NSBezierPath, appendBezierPathWithArcWithCenter (2)
From: |
Georg Fleischmann |
Subject: |
Fix: NSBezierPath, appendBezierPathWithArcWithCenter (2) |
Date: |
Mon, 5 Mar 2001 16:32:11 +0100 |
> I sligthly simplified the
> formula used for F - not that I changed it (unless I made a typo) - just
> did some trivial algebraic/trigonometric simplifications. But as I didn't
> test it, please tell me if I did something wrong.
It works fine.
Now, here is the fix for the remaining problem, I mentioned.
It also makes the code a little bit shorter.
The problem was that circles (360 degree arcs) collapsed to zero in some cases.
Georg
2001-03-05 Georg Fleischmann
* gui/Source/NSBezierPath.m
[NSBezierPath appendBezierPathWithArcWithCenter: ...]:
Rearranged handling of start/end angles to avoid collapsing of
360 degree arcs.
diff -u gui/Source/NSBezierPath.m.old gui/Source/NSBezierPath.m
--- gui/Source/NSBezierPath.m.old Thu Mar 1 16:34:52 2001
+++ gui/Source/NSBezierPath.m Mon Mar 5 16:04:01 2001
@@ -849,10 +849,18 @@
while (startAngle > 360)
startAngle = startAngle - 360;
- while (endAngle < 0)
- endAngle = endAngle + 360;
- while (endAngle > 360)
- endAngle = endAngle - 360;
+ if (clockwise)
+ {
+ while (startAngle < endAngle)
+ endAngle -= 360;
+ diff = -PI / 2;
+ }
+ else
+ {
+ while (endAngle < startAngle)
+ endAngle += 360;
+ diff = PI / 2;
+ }
/* Convert the angles to radians */
startAngle_rad = PI * startAngle / 180;
@@ -862,23 +870,6 @@
p0 = NSMakePoint (center.x + radius * cos (startAngle_rad),
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))
- Fix: NSBezierPath, appendBezierPathWithArcWithCenter (2),
Georg Fleischmann <=