On Sun, 21 Aug 2011 01:58:52 -0700, Matthias Melcher
<[email protected]> wrote:
>
>On 20.08.2011, at 22:55, 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);
>> }
>
>The WIN32 API uses different coordinates than the OS X and X11 API.
>Especially with round drawings that should use floating point coordinates,
>the those errors become visible. FLTK tries its best to make fl_... graphics
>calls look the same on all platforms, but that is not always possible.
The floating point values would be the start and end degrees for the
arc, these are floating point values.
The problem is on the radius, X11 requires the radius to be increased
by one, radius is an int value, floating point has nothing to do with
it.
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.
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.
The out by one error extends to line as well.
#ifndef WIN32
fl_line(c_x, c_y, c_x - offset, c_y + offset);
fl_yxline(c_x, c_y, c_y + r);
#else
fl_line(c_x - 1, c_y, c_x - offset - 1, c_y + offset);
fl_yxline(c_x, c_y, c_y + r - 1);
#endif
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.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk