Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Turtle Graphics [11/12]

This program answers the question: What if the line length increases and the color changes?

* * *

The state of the pen consists of the following properties: color, width, position and direction. These properties are implemented as variables penColor, penWidth, penPos and penDir. The variable penPos is a point of type point2D and variable penDir is a vector of type vector2D. There are two limitations on the possible values of these variables, namely: penWidth must be positive and penDir must be a unit vector (a vector of length 1).

The user-defined procedure InitPen procedure sets the pen's initial state. The starting state of the pen is: white color, width of 4, position at the screen center and direction to the right.

The definition of this procedure is given at the beginning of the second part of the source code.

Loading...