import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.util.Random;


/*
 * Cloud Tutorial - A random cartoon cloud generator
 * Copyright (c) 2007 Alexander Hristov. See http://www.ahristov.com/tutorial for more tutorials
 * 
 * This application is free software; you can redistribute it and/or modify it under the terms 
 * of the GNU Lesser General Public License as published by the Free Software Foundation; 
 * version 2.1 of the License.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with this library; 
 * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 * MA 02111-1307 USA 
 */
public class CloudsTutorial extends Frame {
	public static final double MIN_X = -1024/2.0;
	public static final double MAX_X = 1024/2.0;
	public static final int WIDTH = 1024;
	public static final int HEIGHT = 768;
	
		
	public static void main(String[] x) {
		new CloudsTutorial();
	}
	
	
	public CloudsTutorial() {
		setBounds(0,0,WIDTH,HEIGHT);
		setVisible(true);
		addWindowListener(
				new WindowAdapter() {
					public void windowClosing(WindowEvent e) {
						System.exit(0);
					}
				}
		);
	}
	
	
	public void paint(Graphics gg) {
		Random rnd = new Random();
		Graphics2D g = (Graphics2D)gg;
		
		g.setColor(Color.white);
		g.fillRect(0,0,WIDTH,HEIGHT);
		
		int xc = 300;
		int yc = 300;
		int cloudWidth = 150;
		int cloudHeight = 75;
		
		Area cloud = null;
		for (int i = 0; i < 10; i++) {
			int x = xc+rnd.nextInt(50)-25;
			int y = yc+rnd.nextInt(50)-25;
			int rx = rnd.nextInt(cloudWidth-100)+100;
			int ry = rnd.nextInt(cloudHeight-25)+25;
			Area newPart = new Area(new Ellipse2D.Double(x,y,rx,ry)); 
			if (cloud == null)
				cloud = newPart; 
			else
				cloud.add(newPart);
		}
		
		g.setColor(Color.darkGray);
		g.fill(cloud);
		g.translate(-5,-5);
		g.setColor(new Color(117,197,240));
		g.fill(cloud);

	}
}

