Any trick to inverse fill from Path?


#1

I am currently using the Path class to implement (alpha blended) selections on a GUI and it works OK otherwise but I can't figure out any nice way to make an inverse fill out of the path. (To allow for inverting the user selection.)

Maybe Path is the wrong class to use for this to begin with? But it sure is pretty convenient to allow for "lasso" style selections, for example.


#2

Not sure I understand - do you want your lassoed area to effectively cut out of the full rectangle? If so, then draw the rectangle, change the winding rule with setUsingNonZeroWinding() and then add the lasso path.


#3

Starting from a state like shown in the screenshot, I would like to switch the filled in area to be outside the freeform selection, leaving the lassoed area in its original state.


#4

Yes, Andrew's suggestion is what you need to do then.


#5

OK, I was able to implement this by adding a rectangle into the Path and setting the winding rule as needed.