Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » DrawArc bug ?
DrawArc bug ? [message #16664] Sun, 06 July 2008 16:56 Go to next message
mdelfede is currently offline  mdelfede
Messages: 1307
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 ! Smile
The circle is correct, I mean the center and radius are right, just start and endpoint are mistaken.

Max
index.php?t=getfile&id=1249&private=0
  • Attachment: DrawArc.jpg
    (Size: 14.79KB, Downloaded 660 times)
Re: DrawArc bug ? [message #16665 is a reply to message #16664] Sun, 06 July 2008 17:52 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Well, a problem, a solution ! Smile

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

index.php?t=getfile&id=1250&private=0
  • Attachment: DrawArc2.jpg
    (Size: 15.03KB, Downloaded 625 times)
Re: DrawArc bug ? [message #16703 is a reply to message #16665] Tue, 08 July 2008 00:18 Go to previous message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
still not in uvs... updated on svn.

Ciao

Max
Previous Topic: TIFF reader not reading geotiffs
Next Topic: Premultiply - Wrong expression
Goto Forum:
  


Current Time: Thu Apr 18 07:36:48 CEST 2024

Total time taken to generate the page: 0.03903 seconds