Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » DrawArc bug ?
DrawArc bug ? [message #16664] |
Sun, 06 July 2008 16:56 |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
Here is an arc (look at the outermost one, for example...) which is drawn by
DrawArc(
Rect(11, 58, 291, 338),
Point(274, 130),
Point(27, 130)
);
Where the center point is Point(151, 198).
It's obvious what I want to get, and it's also obvious that I don't !
The circle is correct, I mean the center and radius are right, just start and endpoint are mistaken.
Max
-
Attachment: DrawArc.jpg
(Size: 14.79KB, Downloaded 710 times)
|
|
|
Re: DrawArc bug ? [message #16665 is a reply to message #16664] |
Sun, 06 July 2008 17:52 |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
Well, a problem, a solution !
In DrawOpX11.cpp, from line 297 :
void Draw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color)
{
DrawLock __;
XGCValues gcv, gcv_old;
XGetGCValues(Xdisplay, GetGC(), GCForeground, &gcv_old);
Point offset = GetOffset();
gcv.foreground = GetXPixel(color);
XChangeGC(Xdisplay, GetGC(), GCForeground, &gcv);
Point centre = rc.CenterPoint();
int angle1 = fround(360 * 64 / (2 * M_PI) *
atan2(centre.y - start.y, start.x - centre.x));
int angle2 = fround(360 * 64 / (2 * M_PI) *
atan2(centre.y - end.y, end.x - centre.x));
if(angle2 <= angle1)
angle2 += 360 * 64;
angle2 -= angle1;
XDrawArc(Xdisplay, GetDrawable(), GetGC(), rc.left + offset.x, rc.top + offset.y,
rc.Width(), rc.Height(), angle1, angle2);
XChangeGC(Xdisplay, GetGC(), GCForeground, &gcv_old);
}
The arguments of atan2 where reversed (y must be first...) and the angle2 must be relative to angle1.
Here attached the (right) resulting picture... still a small glitch due to rounding, but ok.
Ciao
Max
-
Attachment: DrawArc2.jpg
(Size: 15.03KB, Downloaded 672 times)
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 23:14:06 CEST 2024
Total time taken to generate the page: 0.07124 seconds
|