Learn to Program with ZedLX

Free Online Programming Course for Beginners

Simple Graphics [7/15]

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

The disc procedure has an optional fourth argument: color. If omitted, the disc is painted in the current global foreground color, which is initially white.

Note: In each of the exercises, make sure to include any changes made in the previous exercises, as each exercise builds upon the previous ones. When you have completed an exercise, always run the program to see the results.

Exercises:

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

    Solution

        disc(480, 360, i*5, /green);
  2. Insert this statement just below the fillScr statement: println "This program draws a growing disc";

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

  4. Insert this statement at the beginning of the loop's body: fillScr(/violet);

  5. Change the println statement in the for loop to also print the value of variable i in each iteration.

Solution

    println "One iteration executed, ", i;

Loading...