Learn Programming - ZedLX

A Free Computer Programming Tutorial for Beginners

Computer Graphics Exercises [1/10]

Computer Graphics Exercises

This program draws four discs lying on a diagonal line. For all given discs, the distance to the top of the screen equals the distance to the left edge of the screen. This implies that the coordinates x and y of disc centers are identical for any given disc.

Exercise 'diagonal 1A' output image

Exercise 1:

Draw a disc colored in cyan somewhere on a line between the blue and the green disc.

Solution 1

disc(210, 210, 50, /cyan);
Exercise 'diagonal 1B' output image

Exercise 2:

Draw a disc colored in orange somewhere on a line between the red and the purple disc.

Solution 2

disc(470, 470, 50, /orange);