On 21.08.2011 20:13, Richard Sanders wrote:

>>> There seems to be an out by one error in drawing coordinate between
>>> win32 and X11/
>>>
>>> Here is an example
>>>
>>> static void DrawRod(int x, int y, int d)
>>> {
>>>   int r = d>>  1;
>>>   fl_color(FL_RED);
>>> #ifdef WIN32
>>>   fl_pie(x, y, d, d, 0, 360);
>>> #else
>>>   fl_pie(x, y, d + 1, d + 1, 0, 360);
>>> #endif
>>>   fl_color(FL_BLACK);
>>>   fl_circle(x + r, y + r, r);
>>> }

 From your code I can't see a direct evidence that this is any better
than not adding 1. I do agree though that there are small differences
in the drawing results between Windows and Linux.

For such tests you should look at test/unittests (in file
test/unittest_circles.cxx). I modified it according to your recipe
above, but with this "fix" the pie becomes asymmetric, hence a better
"fix" might be to subtract 1 from x and 1 and to add 2 to w and h
(your 'd' parameter above). However, this result looks worse than
the original (IMHO) and it extends beyond the green borders in a
few pixels. So, I'd say, as Matt stated already: it is not always
possible to achieve exactly the same results on all platforms, and
I consider the existing implementation the best compromise. YMMV.

> Other funnies I have found
>
> #ifndef WIN32
>      fl_pie(c_x - r, c_y - r, r + r + 1, r + r + 1, 315, 225);
> #else
>      fl_pie(c_x - r, c_y - r, r + r , r + r, 225, 315);
> #endif
>
> Notice that the radius has to be increased by 1 for X11.

See above.

> Also note that for the desired portion of the arc to be drawn it is
> necessary for the start and end point degrees to be reversed.

Here you're definitely wrong. Please see the docs of fl_pie():
"a1,a2  start and end angles of arc measured in degrees counter-
clockwise from 3 o'clock. a2 must be greater than or equal to a1."

If you used the correct order, then it would draw correctly on all
platforms. Note that this also means that you'd sometimes need to
use negative values for the angles (this ought to be documented
better). You can see examples for this in unittest_circles.cxx.

> I may be wrong in my thinking but I think that a cross platform
> library should iron out things like out by one and reversal of start
> stop degrees when drawing an arc.

You're right, but this can only be done as far as possible w/o
other negative effects. The fact that your Windows version with
arcs "315, 225" draws as you expect is a platform-specific side
effect, despite the wrong arguments according to the docs.

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to