java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed

@codeanticode I was testing the features of Pgraphics API, and found this issue with noClip()
Region.Op.REPLACE has been depreceated from Android-API 26 onwards as mentioned in Android-docs here
Now only possible options are INTERSECT and DIFFERENCE . found this on stackoverflow
please guide how to solve this issue !
I don't know if there's any way around this, it seems the Android change just makes it pretty much impossible for Processing to implement the noClip() function as-is at API level 26.
I've been using the following two functions as a compromise - popClip() restores the state before the corresponding pushClip() (which includes resetting more than just the clipping state..):
void pushClip(float x, float y, float x2, float y2) {
if (g instanceof PGraphicsAndroid2D) ((PGraphicsAndroid2D)g).canvas.save();
g.clip(x, y, x2, y2);
}
void popClip() {
if (g instanceof PGraphicsAndroid2D) ((PGraphicsAndroid2D)g).canvas.restore();
else g.noClip();
}
I don't know if there's any way around this, it seems the Android change just makes it pretty much impossible for Processing to implement the
noClip()function as-is at API level 26.I've been using the following two functions as a compromise -
popClip()restores the state before the correspondingpushClip()(which includes resetting more than just the clipping state..):void pushClip(float x, float y, float x2, float y2) { if (g instanceof PGraphicsAndroid2D) ((PGraphicsAndroid2D)g).canvas.save(); g.clip(x, y, x2, y2); } void popClip() { if (g instanceof PGraphicsAndroid2D) ((PGraphicsAndroid2D)g).canvas.restore(); else g.noClip(); }
Hi @dzaima its quite possible to make everything work again without doing much effort, android has deprecated the use of Region.Op.REPLACE but has other enum variables for the same depends upon the function we want to use.
Hi @dzaima its quite possible to make everything work again without doing much effort, android has deprecated the use of Region.Op.REPLACE but has other enum variables for the same depends upon the function we want to use.
The other enum values - INTERSECT and DIFFERENCE - only allow for reducing the size of the clip, whereas noClip() needs to expand it. The removal of Region.Op.REPLACE is specifically because it allowed extending the size of the clip. No other method, other than than restore(), as far as I can tell, can be used to increase the clip size. See the deprecation message here.
Hi @dzaima its quite possible to make everything work again without doing much effort, android has deprecated the use of Region.Op.REPLACE but has other enum variables for the same depends upon the function we want to use.
The other enum values -
INTERSECTandDIFFERENCE- only allow for reducing the size of the clip, whereasnoClip()needs to expand it. The removal ofRegion.Op.REPLACEis specifically because it allowed extending the size of the clip. No other method, other than thanrestore(), as far as I can tell, can be used to increase the clip size. See the deprecation message here.
Agreed with your discussion
Any way to change the android-mode API to still have this option for Android API > 26