StarLogo Project:

Turtle Paint



WHAT IS IT?

This project implements a (very) simple paint program. The turtles do the drawing, but you control the turtles with the mouse.

HOW TO USE IT

Click SETUP to set up the turtles. The NUMBER slider controls the number of turtles. The turtles all start with the color blue.

Click FOLLOW to make the turtles follow the mouse. Wherever you move the mouse, the turtles will follow.

Click TURTLE-PAINT to start painting. When you hold down the mouse button, the turtles will draw.

Click NOISE to add a little randomness to the turtles' movements.

Click SETC COLOR + 1 to make the turtle continuously change their colors.

Click CG to clear the graphics.

THINGS TO NOTICE

There is a lag between the mouse movement and the turtle movement. That's because the turtles are programmed to move just one step and a time, and you can move the mouse much faster. This "lag" can be viewed as either a bug or a feature. You can create some interesting effects that take advantage of the lag. And if you ever want the turtles right under the mouse, just wait a little bit, and the turtles will catch up to the mouse.

When you paint with the NOISE button on, you can get a "spray can" effect in your drawings.

EXPLORATIONS

Create a color palette, so that you can change colors. You can create a type of palette with buttons in the Interface Window. Or you can make a palette with colored patches in the main Graphics window: the program can recognize where you click the mouse and change the turtle colors appropriately.

STARLOGO FEATURES

There are three StarLogo procedures for getting information about the mouse. MOUSE-XCOR reports the mouse's x-coordinate, MOUSE-YCOR reports the mouse's y-coordinate, and MOUSE-DOWN? reports whether the mouse button is pressed.

The FOLLOW button turns on two "forever buttons" (FOLLOW1 and FOLLOW2) to make the turtles follow the mouse. One of the forever buttons (FOLLOW1) sets the values of two observer variables with the mouse coordinates. The other forever button (FOLLOW2) makes the turtles move toward those observer variables. This two-step process improves performance. The obvious one-stop approach (TOWARDS MOUSE-XCOR MOUSE-YCOR) would be slow, since every turtle would need to call the observer procedures MOUSE-XCOR and MOUSE-YCOR. It is much faster for the turtles to access the values of the observer variables.