Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Simple Graphics [7/15]

The fillScr statement fills the entire screen with the given color.

The optional fourth argument of the disc statement is color. The color can be ommited from the disc statement, in which case the disc is painted in the global foreground color. The global foreground color is intitially the white color.

Exercises:

1. Change the program so that the disc is painted in green color.

Solution

    disc(480, 360, i*5, /green);

2. Insert the statement println "This program draws a growing disc"; just below the fillScr statement.

3. Insert the statement println "One iteration executed"; just above the disc statement.

4. Insert the statement fillScr(/violet); as the first statement in the body of the for loop.

5. Change the println statement in the for loop so that it also prints out the value of variable i in each iteration.

Solution

    println "One iteration executed, ", i;

Loading...