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 
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 counterclockwise 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 reordered 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,300i));
vertices.Add(Point(300i,300i));
vertices.Add(Point(300i,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 counterclockwise 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,300i));
vertices.Add(Point(300i,300i));
vertices.Add(Point(300i,i));
vertices.Add(Point(i,i));
}
else{ // CW
vertices.Add(Point(i,i));
vertices.Add(Point(300i,i));
vertices.Add(Point(300i,300i));
vertices.Add(Point(i,300i));
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





Goto Forum:
Current Time: Thu Nov 21 19:43:44 CET 2019
Total time taken to generate the page: 0.01120 seconds
