// GraphicsDemo.java
// Tries out fonts, colors and shapes
// APPLET CODE="GraphicsDemo" WIDTH=500 HEIGHT=400
import java.awt.*;
import javax.swing.*;

public class GraphicsDemo extends JApplet {
	Font f1, f2;
	Color c1, c2;
	int size;
	String s;
	Polygon pBig, pLittle;
	
	public void init( ) {
		size = 32;
		f1 = new Font( "TimesRoman", Font.BOLD, size );
		f2 = new Font( "Dialog", Font.ITALIC, size + 16 );

		c1 = new Color( 139, 0, 139 );
		c2 = new Color( 0, 230, 200 );

		s = "I am the Lorax";

		pBig = new Polygon( );
		pLittle = new Polygon( );		
	}

	public void paint( Graphics g ) {
		g.setFont( f1 );
		g.setColor( c1 );
		g.drawString( s, 20, 50 );
		g.setFont( f2 );
		g.setColor( c2 );
		g.drawString( s, 20, 100 );
		g.setColor( c1 );
		g.drawLine( 10, 10, 40, 300 );
		g.fillRect( 100, 100, 200, 100 );
		g.clearRect( 150, 125, 100, 50 );

		g.setColor( c2 );
		g.fillRoundRect( 100, 250, 80, 80, 80, 80 );
		
		g.fillOval( 250, 250, 100, 50 );
		g.fillArc( 150, 125, 100, 50, 30, 180 );
		g.setColor( c1 );

		// Polygons
		pBig.addPoint( 365, 105 );
		pBig.addPoint( 375, 120 );
		pBig.addPoint( 470, 170 );
		pBig.addPoint( 375, 150 );
		pBig.addPoint( 365, 105 );

		pLittle.addPoint( 270, 20 );
		pLittle.addPoint( 290, 40 );
		pLittle.addPoint( 270, 60 );
		pLittle.addPoint( 270, 20 );
		
		g.setColor( Color.red );
		g.drawPolygon( pBig );
		g.setColor( Color.green );
		g.fillPolygon( pLittle );
	}
}