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 not working in GTK mode
Re: DrawArc not working in GTK mode [message #50231 is a reply to message #50230] Fri, 31 August 2018 13:17 Go to previous messageGo to previous message
mdelfede is currently offline  mdelfede
Messages: 1310
Registered: September 2007
Ultimate Contributor
Found it... Cairo doesn't draw anything with ang1 == ang2. Modifying DrawArcOp like this works:

void SystemDraw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color)
{
	if(rc.Width() <= 0 || rc.Height() <= 0)
		return;
	FlushText();
	Sizef radius = Sizef(rc.Size()) / 2.0;
	Pointf center = Pointf(rc.TopLeft()) + radius;
	double ang1 = Bearing((Pointf(start) - center) / radius);
	double ang2 = Bearing((Pointf(end) - center) / radius);
--->	if(ang1 == ang2)
--->		ang1 -= 0.000001;
	
	cairo_move_to(cr, center.x + radius.cx * cos(ang1), center.y + radius.cy * sin(ang1));
	cairo_save(cr);
	cairo_translate(cr, rc.left + radius.cx, rc.top + radius.cy);
	cairo_scale(cr, radius.cx, radius.cy);
	cairo_arc_negative(cr, 0, 0, 1, ang1, ang2);
	cairo_restore(cr);

	SetColor(color);
	sDrawLineStroke(cr, width);
}


BTW line thickness is much smaller in Cairo than in X11.
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: What is the best way to handle scaling icons?
Next Topic: JPEG Images do not get rotated correctly
Goto Forum:
  


Current Time: Tue Aug 26 01:06:28 CEST 2025

Total time taken to generate the page: 0.06285 seconds