StickFigure


Your browser is ignoring the <APPLET> tag!

This program draws a stick figure when the program starts.

import objectdraw.*;
import java.awt.*;

/**
 * This program draws a single stick figure on the display
 * 
 * @author Barbara Lerner
 * @version March 3, 2008
 */
public class DrawAStickFigure extends WindowController
{
    /**
     * Draw a stick figure.
     */
    public void begin() {
        resize (600, 600);
        new StickFigure (canvas);
    }
}

import objectdraw.*;
import java.awt.*;

/**
 * Draws the shapes that make up a stick figure
 * 
 * @author Barbara Lerner
 * @version March 3, 2008
 */
public class StickFigure
{
    /**
     * Draw a stick figure as a collection of simple geometric shapes.
     */
    public StickFigure (DrawingCanvas figureCanvas) {
        // Draw the head.
        new FramedOval (100, 100, 100, 100, figureCanvas);
        
        // Draw the body
        new Line (150, 200, 150, 400, figureCanvas);
        
        // Draw the arms.
        new Line (150, 250, 100, 200, figureCanvas);
        new Line (150, 250, 200, 200, figureCanvas);
        
        // Draw the legs.
        new Line (150, 400, 100, 500, figureCanvas);
        new Line (150, 400, 200, 500, figureCanvas);
    }
}