Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » DrawArc bug ?
Re: DrawArc bug ? [message #16665 is a reply to message #16664] |
Sun, 06 July 2008 17:52 |
mdelfede
Messages: 1307 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 627 times)
|
|
|
Goto Forum:
Current Time: Fri Apr 26 00:09:20 CEST 2024
Total time taken to generate the page: 0.05067 seconds
|