Author: spitzak
Date: 2007-04-10 06:40:18 -0400 (Tue, 10 Apr 2007)
New Revision: 5769
Log:
Fixed addarc on Cairo/Quartz.
Modified:
trunk/src/addarc.cxx
trunk/src/path.cxx
Modified: trunk/src/addarc.cxx
===================================================================
--- trunk/src/addarc.cxx 2007-04-08 19:58:56 UTC (rev 5768)
+++ trunk/src/addarc.cxx 2007-04-10 10:40:18 UTC (rev 5769)
@@ -98,7 +98,7 @@
int i = int(ceilf(fabsf(angle)/epsilon));// Segments in approximation
if (i > MAXPOINTS-1) i = MAXPOINTS-1;
- if (i) {
+ if (i>0) {
epsilon = angle/i; // Arc length for equal-size steps
// calculate transformation matrix that does rotation by epsilon in
// a scaled by w,h coordinate system. We could in fact figure out a
Modified: trunk/src/path.cxx
===================================================================
--- trunk/src/path.cxx 2007-04-08 19:58:56 UTC (rev 5768)
+++ trunk/src/path.cxx 2007-04-10 10:40:18 UTC (rev 5769)
@@ -343,9 +343,6 @@
}
}
}
-static fltk::Rectangle circle;
-static float circle_start, circle_end;
-enum CircleType {NONE=0, PIE, CHORD} circle_type;
#else
// We have to store the path ourselves on X11 and Win32. Path is stored
// as transformed points plus lengths of "loops".
@@ -382,7 +379,7 @@
// The path also contains one dummy pie/chord piece:
static fltk::Rectangle circle;
static float circle_start, circle_end;
-enum {NONE=0, PIE, CHORD} circle_type;
+static enum {NONE=0, PIE, CHORD} circle_type;
#endif // local path storage
@@ -623,17 +620,12 @@
\see addchord()
*/
void fltk::addpie(const Rectangle& r, float start, float end) {
-#if USE_CAIRO
+#if USE_CAIRO || USE_QUARTZ
closepath();
addvertex(r.x()+r.w()*.5f, r.y()+r.h()*.5f);
- float delta = sqrtf(1/(m.a*m.a+m.d*m.d));
+ float delta = sqrtf(1/fabsf(m.a*m.d-m.b*m.c));
addarc(r.x()+delta/2, r.y()+delta/2, r.w()-delta, r.h()-delta, start, end);
closepath();
-#elif USE_QUARTZ
- circle = r;
- circle_start = start;
- circle_end = end;
- circle_type = PIE;
#else
transform(r, circle);
circle_start = start;
@@ -654,15 +646,10 @@
of a closed version draws the straight edge is indeterminate.
*/
void fltk::addchord(const Rectangle& r, float start, float end) {
-#if USE_CAIRO
+#if USE_CAIRO || USE_QUARTZ
closepath();
- float delta = sqrtf(1/(m.a*m.a+m.d*m.d));
+ float delta = sqrtf(1/fabsf(m.a*m.d-m.b*m.c));
addarc(r.x()+delta/2, r.y()+delta/2, r.w()-delta, r.h()-delta, start, end);
-#elif USE_QUARTZ
- circle = r;
- circle_start = start;
- circle_end = end;
- circle_type = CHORD;
#else
transform(r, circle);
circle_start = start;
@@ -676,7 +663,6 @@
cairo_new_path(cc);
#elif USE_QUARTZ
first_point = true;
- circle_type = NONE;
CGContextBeginPath(quartz_gc);
#else
numpoints = loop_start = loops = 0;
@@ -724,13 +710,6 @@
cairo_stroke(cc);
#elif USE_QUARTZ
CGContextStrokePath(quartz_gc);
- if (circle_type) {
- first_point = true;
- CGContextBeginPath(quartz_gc);
- const Rectangle& r = circle;
- addarc(r.x(), r.y(), r.w()-1, r.h()-1, circle_start, circle_end);
- CGContextStrokePath(quartz_gc);
- }
#elif USE_X11
if (circle_type) {
int A = int(circle_start*64);
@@ -798,14 +777,6 @@
cairo_fill(cc);
#elif USE_QUARTZ
CGContextFillPath(quartz_gc);
- if (circle_type) {
- first_point = true;
- CGContextBeginPath(quartz_gc);
- const Rectangle& r = circle;
- addvertex(r.x()+(r.w()-1)*0.5f, r.y()+(r.h()-1)*0.5f);
- addarc(r.x(), r.y(), r.w()-1, r.h()-1, circle_start, circle_end);
- CGContextFillPath(quartz_gc);
- }
#elif USE_X11
if (circle_type) {
int A = int(circle_start*64);
@@ -882,18 +853,6 @@
split_color(color, r, g, b);
CGContextSetRGBStrokeColor(quartz_gc, r/255.0f, g/255.0f, b/255.0f, 1.0);
CGContextDrawPath(quartz_gc, kCGPathFillStroke);
- if (circle_type) {
- first_point = true;
- CGContextBeginPath(quartz_gc);
- const Rectangle& r = circle;
- if (circle_type==PIE) addvertex(r.x()+(r.w()-1)*0.5f,
r.y()+(r.h()-1)*0.5f);
- addarc(r.x(), r.y(), r.w()-1, r.h()-1, circle_start, circle_end);
- CGContextFillPath(quartz_gc);
- first_point = true;
- CGContextBeginPath(quartz_gc);
- addarc(r.x(), r.y(), r.w()-1, r.h()-1, circle_start, circle_end);
- CGContextStrokePath(quartz_gc);
- }
setcolor(color);
inline_newpath();
#elif USE_X11
@@ -902,12 +861,7 @@
int B = int(circle_end*64)-A;
const Rectangle& r = circle;
XSetArcMode(xdisplay, gc, circle_type == PIE ? ArcPieSlice : ArcChord);
- if (r.w() < 2 || r.h() < 2) {
- if (!r.empty())
- XFillRectangle(xdisplay, xwindow, gc, r.x(), r.y(), r.w(), r.h());
- } else {
- XFillArc(xdisplay, xwindow, gc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
- }
+ XFillArc(xdisplay, xwindow, gc, r.x(), r.y(), r.w()-1, r.h()-1, A, B);
}
closepath();
if (numpoints > 2) {
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit