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 » Problem with polygon inside polygon... in Painter
Problem with polygon inside polygon... in Painter [message #34376] Sat, 19 November 2011 12:30 Go to next message
Tom1
Messages: 659
Registered: March 2007
Contributor
Hi,

I have run into trouble rendering maps using Painter. When there is an island within a pond within an island within a lake.... well you know, this is a nested polygon problem and rendering this complex polygon describing the water colored areas -- as well as the differently colored polygon describing the land areas produce unsatisfactory results. With X and GDI this works perfectly, but with painter there is a prerequisite to order the vertices at each nesting level to an alternating clockwise and counter-clockwise order.

Is there a possibility to change Painter to render polygons inside polygons using the same coverage logic as X and GDI does?

Here is a test case showing a green reference with X/GDI, a Painter result in red and a re-ordered Painter result in blue:

	void Paint(Draw &w){
		Rect rect=GetSize();
		w.DrawRect(rect,White());
		
		// Create geometry (a polygon inside a polygon inside a polygon ...)
		Vector<Point> vertices;
		for(int i=0;i<80;i+=10){
			vertices.Add(Point(i,i));
			vertices.Add(Point(i,300-i));
			vertices.Add(Point(300-i,300-i));
			vertices.Add(Point(300-i,i));
			vertices.Add(Point(i,i));
		}

		// Draw reference geometry
		w.DrawPolygon(vertices,Green());

		// Draw painter geometry
		PaintingPainter pn(300,300);
		pn.Clear(White());
		pn.DrawPolygon(vertices,Red());
		w.DrawPainting(300,0,300,300,pn);
		
		// Create geometry (a polygon inside a polygon inside a polygon ...)
		// This time only with alternating clockwise and counter-clockwise vertex ordering
		vertices.Clear();
		for(int i=0;i<80;i+=10){
			if((i/10)%2){ // CCW
				vertices.Add(Point(i,i));
				vertices.Add(Point(i,300-i));
				vertices.Add(Point(300-i,300-i));
				vertices.Add(Point(300-i,i));
				vertices.Add(Point(i,i));
			}
			else{	// CW
				vertices.Add(Point(i,i));
				vertices.Add(Point(300-i,i));
				vertices.Add(Point(300-i,300-i));
				vertices.Add(Point(i,300-i));
				vertices.Add(Point(i,i));
			}
		}

		// Draw alternate painter geometry
		pn.Clear(White());
		pn.DrawPolygon(vertices,Blue());
		w.DrawPainting(600,0,300,300,pn);
	}


Best regards,

Tom
Re: Problem with polygon inside polygon... in Painter [message #34377 is a reply to message #34376] Sat, 19 November 2011 12:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
pn.EvenOdd();

Mirek
Re: Problem with polygon inside polygon... in Painter [message #34378 is a reply to message #34377] Sat, 19 November 2011 13:36 Go to previous message
Tom1
Messages: 659
Registered: March 2007
Contributor
Thanks!

Best regards,

Tom
Previous Topic: Draw sharp lines using Painter
Next Topic: Paint dashed polyline
Goto Forum:
  


Current Time: Thu Nov 21 19:43:44 CET 2019

Total time taken to generate the page: 0.01120 seconds