Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: draw outside of closed path instead of inside

I am drawing a filled polygon on a canvas in android.

canvas.drawPath(path,myPaint);

Now I want to do exactly the opposite: Fill the area outside of the polygon.

how can I tell the paint to fill the outer region - the region which is not covered by the polygon?

like image 437
stoefln Avatar asked May 28 '12 23:05

stoefln


2 Answers

simply use

path.setFillType(FillType.INVERSE_EVEN_ODD);
like image 94
Moxor Avatar answered Nov 15 '22 00:11

Moxor


This can be complicated or very simple.

The complicated way:

Create a path exactly like your polygon, except don't close it. The continue that path to the nearest wall. Draw around the walls. Close and fill. In code, this isn't too fun.

The simple way:

Color the canvas. Draw the polygon.

Good luck.

like image 42
Zaid Daghestani Avatar answered Nov 15 '22 00:11

Zaid Daghestani