Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(py)cairo - fill

is there a way to fill everything outside of a closed path (polygon)?

Background: I'd like to render some maps with coastlines - so sometimes I need to fill the sea with blue color, so I thought it would be the easiest and in my situation the most efficient to fill everything outside of this coastline polygon with blue color.

Thanks in advance!

like image 805
xyz-123 Avatar asked Oct 13 '22 21:10

xyz-123


1 Answers

You can add a rectangle covering the whole drawing area to your coastline path and set the fill rule to cairo.FILL_RULE_EVEN_ODD. Calling fill() after this fills the area outside your original path. (If you choose the correct orientation for your rectangle you can skip setting the fill rule.)

like image 144
Sven Marnach Avatar answered Nov 15 '22 08:11

Sven Marnach