import acm.graphics.*; import java.awt.*; import acm.program.*; /** An instance maintains a graphics window on the monitor, which can be drawn on * using pens, turtles, and other things. */ public class GDemo extends GraphicsProgram { // The width and height of the graphics window. // DO NOT WORRY ABOUT WHAT THIS DOES! private static String[] sizeArgs= { "width=" + 500, "height=" + 500 }; /** Constructor: a new Graphics Program with a canvas of size (500, 500) */ public GDemo() { super(); start(sizeArgs); } /** Yields a new turtle that is at the Center of the canvas, faces west, * is not hidden, and is ready to draw in blue. */ public GTurtle getTurtle() { GTurtle t= new GTurtle(); add(t); // Add the turtle to the canvas. t.setLocation(getWidth()/2, getHeight()/2); t.penDown(); t.setColor(Color.blue); t.setDirection(180); t.showTurtle(); return t; } /** Yields: a new pen that is at the Center of the window, * is not hidden, and is ready to draw in black. */ public GPen getPen() { GPen p= new GPen(); add(p); // Add the pen to the canvas. p.setLocation(getWidth()/2, getHeight()/2); p.setColor(Color.black); p.showPen(); return p; } }