setClip

My first question is:
Is g.setClip time consuming?

in my canvas, I draw many sprites using:
for(…) {
g.setClip(x, y, imgW,imgH);
g.drawImage(myImage, imgX, imgY, MY_FLAGS);
g.setClip(0, 0, screenWidth, screenHeight);
}

I’d like to know the purpose of a call to:
g.setClip(0, 0, screenWidth, screenHeight);

Is it to flag the part of the screen to refresh?
Can call it only one time after all my sprites are drawn?
Or do i have to call it for each sprite?

Franck

if you can guarantee setClip will be called before all drawImage operations, the 2nd setClip…


g.setClip(0, 0, screenWidth, screenHeight);

… is completely redundant.

As to the purpose of setClip, its simply to modify the clip rectangle associated with the a given Graphics context.

Rendering operations can only effect pixels that fall within the bounds of the current clip rectangle. (as specified by the most recent call to setClip())