Class Pen
- public class Pen
A simple Pen class which implements turtle style graphics.
The pen has a position and an angle, and can be either up or down.
All distances are in pixels. Angles are specified in degrees.
- Version:
- $Id: Pen.java,v 1.2 2001/04/04 03:25:12 administrator Exp $
- Author:
- Ben Dugan
Pen
public Pen()
- Create a new Pen. By default, the pen is created in the down state,
and positioned in the center of the window, facing right (angle
0).
down
public void down()
- Set the pen's state to down.
up
public void up()
- Raise the pen.
erase
public void erase()
- Erase the window.
home
public void home()
- Send the pen to the home position.
turn
public void turn(int degrees)
- Turn the pen this many degrees.
- Parameters:
degrees
- a positive number is degrees to the "left"
move
public void move(int distance)
- Move the pen the given distance. If the pen is down, a line
is drawn.
toString
public java.lang.String toString()
- Return the pen's printed representation.
- Overrides:
toString
in class java.lang.Object
squiral
public void squiral(int steps,
int angle,
int distance)
- Draw a squiral.
- Parameters:
steps
- the number of steps (lines) to drawangle
- the amount to turn after each stepdistance
- the length by which to grow every third line
main
public static void main(java.lang.String[] args)
- Test the pen with the squiral method.