package bulles;

import java.awt.*;
import abstractAnimation.DoubledBufferedAnimationApplet;


public class Bulles extends DoubledBufferedAnimationApplet 
{
	/**
	 * Permet l'exécution en tant qu'application
	 * @param applet
	 * @param arguments
	 */
	public static void main(String [] arguments)
	{
		DoubledBufferedAnimationApplet.main(new Bulles(), arguments);
	}

	/**
	 * remise à "zero" de l'animation.
	 * (re)initialisation des coordonnées des objets de l'animation, etc.
	 */
	protected void reset()
	{
	}
	
	/**
	 * "battement" de l'animation.
	 * mise à jour des coordonnées des objets de l'animation, etc.
	 */
	protected void tick()
	{
	}

	/**
	 * le traçage proprement dit du dessin.
	 */
	protected void trace(Graphics graphics, Dimension dimension)
	{
	    graphics.setColor(Color.BLACK);
	    graphics.fillRect(0, 0, dimension.width, dimension.height);
	    for(int i = 0 ; i < 32 ; ++i)
	    {
		    graphics.setColor(new Color((float)Math.random(), (float)Math.random(), (float)Math.random()));
		    final int l = (int)(Math.random() * dimension.width);
		    final int r = (int)(Math.random() * dimension.width);
		    final int t = (int)(Math.random() * dimension.height);
		    final int b = (int)(Math.random() * dimension.height);
		    final int x = Math.min(l, r);
		    final int y = Math.min(t, b);
		    final int w = Math.max(l, r) - x;
		    final int h = Math.max(t, b) - y;
		    graphics.fillOval(x, y, w, h);
	    }
	}
}

