Reset clip region on Graphics

For example, having this:

[code]// reduce clip region to certain part of screen

// draw stuff here (clipped to the region reduced above)
// …

// end clipping

Just wondering if there’s a more elegant call to restore default clip region for the current graphic context, because under osx seems the last line throws assertion (doesnt do under WinXP).

You can save the clip and restore it like this:

    const RectangleList originalClipRegion (g.getClipRegion());


    g.setClipRegion (originalClipRegion);

It’s very dodgy to set it to your own rectangle, because this might push it beyond the edges of the image it’s drawing onto.


Sorry for kicking this old topic, but how would this be done in the latest version of JUCE? There’s no more Graphics.setClipRegion function…

I’m pretty new to JUCE, and I’m probably missing something stupidly obvious here, but I can’t find how to increase/reset the clipping rectangle.

graphics->reduceClipRegion(100, 100, 50, 50);

//This obviously doesn't work, as it isn't much of a reduction:


There’s no way to do that, and no need.

If you want to reduce the clip and then reset it, you’d do something like this:

g.reduceClipRegion (…);
…draw here with the reduced region

…and it’s back to normal here[/code]

1 Like

Thanks! :smiley: