|
Next week's lab we will be having a beauty pageant in lab class. You are to create the contestants. Be creative, your peers will be judging. In lecture on Friday I made an applet and used the Graphics2D class to draw objects on the screen. I went over the Graphics class using fillRect, drawRect and many more of the drawing capabilities. You have an Outlab due next Tuesday that is drawing a head (get as fancy as you want). Below is an example of a head I did Monday afternoon. If you have looked at chapter 4 in the Textbook, they have a similar example for drawing a car. |
|
|
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. Your outlab next Tuesday is to create a head of your own using the ovals, rects, and anything else in the Graphics class that you wish to use. You will have a beauty pageant in the lab Tuesday. I wish each of you the best of luck, be creative. Can you create the ultimate in Applet Beauty? I expect you to do much better than the one above. | |
Advanced topics
| |