diff --git a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java index f477623..1807104 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PCanvas.java @@ -35,6 +35,7 @@ import java.awt.Graphics2D; import java.awt.KeyEventPostProcessor; import java.awt.KeyboardFocusManager; +import java.awt.Rectangle; import java.awt.event.ActionListener; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; @@ -565,6 +566,8 @@ repaint((int) bounds.x, (int) bounds.y, (int) bounds.width, (int) bounds.height); } + private PBounds repaintBounds = new PBounds(); + /** * {@inheritDoc} */ @@ -581,6 +584,10 @@ g2.fillRect(0, 0, getWidth(), getHeight()); } + if (getAnimating()) { + repaintBounds.add(g2.getClipBounds()); + } + // create new paint context and set render quality to lowest common // denominator render quality. final PPaintContext paintContext = new PPaintContext(g2); @@ -596,16 +603,16 @@ paintContext.setRenderQuality(normalRenderQuality); } - // paint piccolo camera.fullPaint(paintContext); // if switched state from animating to not animating invalidate the - // entire - // screen so that it will be drawn with the default instead of animating - // render quality. + // repaint bounds so that it will be drawn with the default instead of + // animating render quality. if (!getAnimating() && animatingOnLastPaint) { - repaint(); + repaint(repaintBounds); + repaintBounds.reset(); } + animatingOnLastPaint = getAnimating(); PDebug.endProcessingOutput(g2);