More on Turtle Graphics

Samuel Marateck

The following are background colors and are used in the command graphBackground( n ), where n is the color

black = 0
blue = 1
green = 2
cyan = 3
read = 4
magenta = 5
brown = 6
light grey = 7
dark grey = 8
light blue = 9
light green = 10
light cyan = 11
light red = 12
light magenta = 13
yellow = 14
white = 15

In order to use this, you must first have uses graph3 as the first statement in your program after the program header. Then you must precede the graphBackground statement with GraphColorMode.

The most suitable palette for project 1 is palette 3, in which the forground colors are:

blue = 1
red = 2
white = 3

To draw a line use draw( x1, y1, x2, y2 ), where x1, y1 are the coordinates of one end of the line and x2, y2, are those of the other. Note that the x-coordinate of the upper right side of the screen is 319 and the y-coordinate is 0. The (x, y) of the lower right side is (319, 199). The upper left side coordinate is (0, 0). The middle is (159, 99)

To draw a circle, use circle( x, y, radius, color ). Thus circle( 159, 99, 5, 3 ) would draw a circle at the center of the screen in white with a radius of 5.

To fill an enclosed figure with a given color, use fillshape( x, y, color, 2 ), where x and y must be in the enclosed figure to be colored. The 2 must be used as the 4th parameter for some unknown reason. Thus fillshape( 159, 99, 1, 2 ) would color the above circle in red.

In order to place text on the graphics screen first add the crt unit to your uses statement. Then use gotoxy( x, y ) where x and y are the column and row of text. This is a different coordinate system than the graphics mode. The screen measures 24 rows by 40 columns. The sound features are also part of the crt unit. The following sequence creates a sound lasting 100 milliseconds and vibrating at 440 cycles per second (cps). Nosound shuts off the sound.

sound( 440 );
delay( 100 );
nosound