import java.awt.*; import java.awt.image.BufferedImage; import java.util.ArrayList; import javax.swing.*; /** * Custom rendering of an image, by animated blobs. * * @author Chris Bailey-Kellogg, Dartmouth CS 10, Fall 2012 * @author CBK, Winter 2014, revised for DrawingFrame and independent Agent files * @author CBK, Spring 2015, DrawingGUI * @author CBK, Spring 2016, revised for Blobs */ public class AnimatedImage extends DrawingGUI { private static final int radius = 5; // setup: blob size private static final int numBlobs = 20000; // setup: how many blobs private static final int numToMove = 1000; // setup: how many blobs to animate each frame private ArrayList blobs; // the blobs representing the picture public AnimatedImage(BufferedImage img) { // Size of the window is scaled up from the original image by the blob radius super("Animated Picture", img.getWidth()*radius, img.getHeight()*radius); // Create a bunch of random blobs. blobs = new ArrayList(); for (int i=0; i