public void paint(Graphics graphics, long time) { // Clear the background. Color outsideColor = outsideClipColor.getColor(time); Rectangle clip = graphics.getClipBounds(); graphics.setPaintMode(); graphics.setColor(outsideColor); graphics.fillRect(0, 0, clip.width, clip.height); // Draw the sprite in XOR mode. OverrideGraphics2D g = new OverrideGraphics2D((Graphics2D) graphics); Color insideColor = insideClipColor.getColor(time); g.setOverrideXORMode(insideColor); sprite.paint(g, time); g.setOverrideXORMode(null); // Clear the clip area. g.setOverrideColor(insideColor); clipSprite.paint(g, time); g.setOverrideColor(null); // Draw the sprite in XOR mode. g.setOverrideXORMode(insideColor); sprite.paint(g, time); g.setOverrideXORMode(null); }
public void paint(Graphics graphics, long time) { // Save the old color. Color oldColor = graphics.getColor(); // Set the new color. graphics.setColor(color.getColor(time)); // Paint the actual sprite. sprite.paint(graphics, time); // Restore the old color. graphics.setColor(oldColor); }