CS 160

February 20, 2004



Today in lecture I made an applet and used graphics calls to attempt to draw a head.
You have an Outlab due Tuesday that is drawing a head (get as fancy as you want). Below is an example of a head I did Friday afternoon.
I will also post the requirements that will be due on Tuesday.
It's all in chapter 4 in the Textbook
ALT="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is ignoring the <APPLET> tag! This applet to the right uses Graphics2D like the book uses. It wouldn't run on my WindowsME machines running IE 5.5
So I ran it on my WindowsXP machine running IE6.0 and it worked. So I wrote the applet twice this code and applet is using the Graphics2D. I included the paint method below.
  	public void paint(Graphics g)
	{
	Graphics2D g2 = (Graphics2D)g;
        g.drawLine(20, 20, 100, 50);
        g.setColor(Color.green);
        g.setColor(Color.red);
        g.drawLine(20, 100, 100, 50);
        g.drawRect(0, 0, 20, 20);
        g.setColor(Color.blue);
        g.drawRect(20, 100, 50, 60);
	}

This applet is the same program but it's just using the regular Graphics class.
   
	public void paint(Graphics g)
	{
		
        g.drawLine(20, 20, 100, 50);
        g.setColor(Color.green);
        g.setColor(Color.red);
        g.drawLine(20, 100, 100, 50);
        g.drawRect(0, 0, 20, 20);
        g.setColor(Color.blue);
        g.drawRect(20, 100, 50, 60);
	}
This an example of a head that I did using Rectangles, ovals, and lines. I ran out of time today, but I'll probably make it a little more extravagant over the weekend. You need to make a similar one for lab on Tuesday.