**clearGraph()**

This command completely erases the graph's drawing surface, including the grid, axes, and origin. By default, this command will leave you with a completely white drawing surface. Use it this way:

clearGraph();

**drawAxes()**

This command draws the x-axis and the y-axis. It is
often called after **drawGrid** and before **drawOrigin**.
Here is how to use it:

drawAxes();

The separate axes are drawn with the colors held in
the variables **xAxisColor** and **yAxisColor**.
These default to 'red' and 'green' respectively. The axes thickness defaults
to 3, and this value is kept in the variable **axisThickness**.

After **drawAxes** executes, the line
color is set to **yAxisColor** (default: 'green') and the line thickness is set to
**axisThickness** (default: 3). You will probably want to change this
situation using
**setLineColor** and **setLineThickness** before
you
subsequently draw.

See: **drawGrid()**,
**drawOrigin()**, **
setLineColor('color')**, **
setLineThickness(n)**

**drawGrid()**

This command draws a grid of lines on the (x, y) plane like the type of grid found on common graph paper. Here is how to use it:

drawGrid();

After **drawGrid** executes, the line
color is set to **gridColor** (default: a light gray) and the line thickness is set to
**gridThickness** (default: 1). You will probably want to change these using
**setLineColor** and **setLineThickness** for your
subsequent drawings.

See: **drawAxes()**,
**drawOrigin()**, **
setLineColor('color')**, **
setLineThickness(n)**

**drawLineSegment(x1, y1, x2, y2)**

This command draws a line segment between the
endpoints given in the parameters. The (x, y) coordinates for one endpoint
are given by the parameters **x1** and **y1**. The parameters
**x2** and **y2** are
the (x, y) coordinates for the other endpoint.

The line is drawn with the current line color and thickness. Here is an example of how to use it:

drawLineSegment(2, 3, 4, 5);

The above code would draw a line segment from point (2, 3) to point (4, 5).

Tutorial: Drawing a line segment

See: **
setLineThickness(n)**, **
setLineColor('color')**

**drawOrigin()**

This command draws a small square at the point (0, 0), the origin of the (x, y) graph. Here is how it is used:

drawOrigin();

After **drawOrigin** executes, the line
color is set to **originLineColor** (default: 'black'), the area color is set to
**originAreaColor** (default: 'white'), and the line thickness is set to
**originLineThickness** (default: 1). You will probably want to change these
using **setLineColor**, **setAreaColor**, and
**setLineThickness** for your
subsequent drawings.

See: **drawAxes()**,,
**drawGrid()**, **
setLineColor('color')**, **
setAreaColor('color')**, **
setLineThickness(n)**

**drawPoint(x, y)**

This command plots a point at the x- and
y-coordinates given by the parameters **x** and **y**, respectively.
Here's how to use it:

point(6, 4);

The above code would plot a point at (6, 4).

Tutorial: Drawing a point

**drawRectangleArea(x, y, width, height)**

This command draws a rectangle filled with the current area color.
The parameters **x** and **y** give the x- and y-coordinates, respectively, for
the upper left corner of the rectangle. The parameters **width** and
**height**
set the width and height, respectively, of the rectangle.

Here is an example of how to use this command:

drawRectangleArea(3, 5, 6, 4);

The above code would place a filled rectangle with its upper left corner at point (3, 5). The rectangle would have a width of 6 and a height of 4.

Tutorial: Drawing a rectangle

See: **
drawRectangleLine(x, y, width, height)**,
**setAreaColor('color')**

**drawRectangleLine(x, y, width, height)**

This command draws the perimeter of a rectangle filled with the
current line color and thickness. The parameters **x** and
**y** give the x- and
y-coordinates, respectively, for the upper left corner of the rectangle. The
parameters **width** and **height** set the width and height, respectively, of
the rectangle.

Here is an example:

drawRectangleLine(2, 4, 5, 3);

The above code would place an outline of a rectangle with its upper left corner at point (2, 4). The rectangle would have a width of 5 and a height of 3.

Tutorial: Drawing a rectangle

See: **
drawRectangleArea(x, y, width, height)**,
**setLineColor('color')**

**rectangleClear(x, y, width, height)**

This command erases all drawing, including grid,
axes, and origin, within the rectangle defined by its parameters. The
parameters **x** and **y** give the x- and y-coordinates, respectively, for the
upper left corner of the rectangle. The parameters **width** and
**height** set
the width and height, respectively, of the rectangle. This is an example of
its use:

rectangleClear(2, 3, 7, 6);

The above code would erase all graphics within a rectangle 7 units wide and 6 units high. The rectangle would be located with its upper left corner at (2, 3).

**setAreaColor('color')**

This command sets the color to be used for any area
drawing command, such as **drawRectangleArea**. The **color** parameter should equal any color value
listed in the color values section. Here's its use:

sesetAreaColor('red');

The above code would cause all following area drawing
commands, such as **drawRectangleArea**, to be filled with the
color red.

See: **
setLineColor('color')**, Language,
Colors

**setBounds(xMin, xMax, yMin, yMax)**

This This commands sets the bounds for the (x, y) graph. The parameters work this way:

**xMin**: the numeric value for the minimum x-coordinate.**xMax**: the numeric value for the maximum x-coordinate.**yMin**: the numeric value for the minimum y-coordinate.**yMax**: the numeric value for the maximum y-coordinate.

Usually, the graph bounds are set using the drop down list of options available on the graph panel. However, they can be also set to any valid values under program control using this command. Here is an example of its use:

setBounds(-5, -5, 5, 5);

When setting bounds with **setBounds**,
**drawGrid** will probably not provide convenient markings for
your graph. The commands **drawAxes** and **drawOrigin**
will work fine, though.

**setLineColor('color')**

This command sets the color to be used for any line
drawing command, such as **drawLineSegment**. The **color** parameter should equal any color value
listed in the color values section. Here is how to use this command:

setLineColor('blue');

See: setAreaColor('color'), Language, Colors

**setLineJoin('type')**

This command sets the appearance of the spot where
line segment endpoints meet. Values for the parameter **type**
can be 'round', 'bevel', or 'miter'. This is how to use **setLineJoin**:

setLineJoin('round');

**setLineCap('type')**

This command sets the appearance of the endpoints for
a line segment. Values for the parameter **type** can be 'butt',
'round', or 'square'. Using this command looks like this:

setLineCap('round');

**setLineThickness(thickness)**

This command sets the thickness of a line segment. The parameter
**thickness** is a numeric value representing the
pixel thickness of the line segment. Here is how to use this command:

setLineThickness(5);

Tutorial:
**forward** and **back**

**setupGraph()**

This command is actually a way to call several common
graphic commands all at once. Basically, **setupGraph** does all of this:

clearGraph(); drawGrid(); drawAxes(); drawOrigin(); setAreaColor('yellow'); setLineThickness(2); setLineColor('black');

As it turns out, **setupGraph** is often
a very convenient way to get things ready for most investigations. Its use
is:

setupGraph();

The examples and tutorials often use **
setupGraph** to prepare the drawing surface.

**back(distance)**

This command moves the turtle backwards through a
distance given by the parameter **distance**. If the pen is down, then a line
will be drawn over this distance. Example:

back(4);

The above code would move the turtle backward 4 units.

This command does not change the turtle's heading. It does not turn the turtle around. The turtle moves like a car in reverse.

Tutorial:
**forward** and **back**

See: **forward(distance)**

**forward(distance)**

This command moves the turtle forward through a
distance given by the parameter **distance**. If the pen is down, then a line
will be drawn over this distance. Example:

forward(3);

The above code moves the turtle in a straight line through a distance of 3 units.

Tutorial:
**forward** and **back**

See: **back(distance)**

**left(angle)**

This command turns the turtle to the left through an
angle given by the parameter **angle**. By default, the
angle is measured in degrees. If you want to work in radians, use the
command **setRadians**. An example:

left(20);

By default, the above code would spin the turtle 20 degrees toward its left.

The turtle stays in place while turning. If you give **left** a negative angle,
then the turtle will turn right.

Tutorial:
**right** and **left**

See: **right(angle)**,
**setRadians()**,
**setDegrees()**

**penDown()**

This command drops the turtle's imaginary pen onto the drawing surface and causes the turtle to draw a line along its path as it moves. By default, the pen is down. This command is used this way:

penDown();

Tutorial:
**penUp** and **penDown**

See: **penUp()**

**penUp()**

This command lifts the turtle's imaginary pen off of the drawing surface; so, the turtle will not draw as it moves. Here's how to use this command:

penUp();

Tutorial:
**penUp** and **penDown**

See: **penDown()**

**right(angle)**

This command turns the turtle to the right through an
angle given by the parameter **angle**. Use it like this:

right(40);

By default, the above code would spin the turtle 40 degrees toward its right.

The turtle stays in place while turning. If you give
**right** a negative angle,
then the turtle will turn left.

Tutorial:
**right** and **left**

See: **left(angle)**,
**setRadians()**,
**setDegrees()**

**setH(angle)**

This command sets the turtle's heading to an angle
given by the parameter **angle**. This angle is in standard position relative
to the graph's axes.

- A heading of 0 degrees is directly right.
- A heading of 90 degrees is directly up.
- A heading of 180 degrees is directly left.
- A heading of 270 degrees is directly down.

The turtle stays in place while turning. Here is an example of using this command:

setH(30);

Assuming the angle measurement is set to its default, the above code would aim the turtle 30 degrees up from the horizontal.

Tutorial:
**setH**

See:
**setRadians()**,
**setDegrees()**

**setX(x)**

This command changes only the x-coordinate for the
turtle. That is, it moves the turtle left or right, but not up or down. The
new x-coordinate is given by the parameter **x**. If the pen is down, the turtle will draw a line
segment as it moves to its new x-coordinate. Here is an example of this
command:

setX(5);

If the turtle was at point (2, 3), it would move to point (5, 3). The x-coordinate would change; the y-coordinate would not change.

Tutorial:
**setX**,
**setY**, and **setXY**

See: **setY(y)**,
**setXY(x, y)**

**setXY(x, y)**

This command changes both the x-coordinate and
y-coordinate for the turtle. The new x- and y-coordinates are given by the
parameters **x** and **y** respectively. If
the pen is down, the turtle will draw a line segment as it moves to its new
x-and y-coordinates. Here is an example of this command:

setXY(5, 7);

If the turtle was at point (2, 3), it would move to point (5, 7). Both the x-and y-coordinates would change.

Tutorial:
**setX**,
**setY**, and **setXY**

**setY(y)**

This command changes only the y-coordinate for the
turtle. That is, it moves the turtle up or down, but not right or left. The
new y-coordinate is given by the parameter **y**. If the pen is down, the turtle will draw a line
segment as it moves to its new y-coordinate. Here is how to use this
command:

setY(7);

If the turtle was at point (2, 3), it would move to point (2, 7). The y-coordinate would change; the x-coordinate would not change.

Tutorial:
**setX**,
**setY**, and **setXY**

See: **setX(x)**,
**setXY(x, y)**

Custom Search