Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Simple Graphics [14/15]

This program draws a bunch of lines. The top line ends move rightward, while the bottom line ends move leftward.
[Run the program]

To accomplish the movemement leftward, a subtraction operation was performed in the third argument of the line procedure call.

Exercise:

Iteration Line Ends 2 Exercise output image

Draw discs at the ends of each line. The radius of discs should be 10 pixels.

Hint 1

Since the lines connect disc centers, disc procedure calls have to use the same coordinates as given in the the line procedure call.

Hint 2

The disc procedure has the form:
disc(x, y, radius)

The line procedure has the form:
line(x1, y1, x2, y2)

Solution

Just above the sleepMs statement, insert: disc(i, 100, 10); disc(960-i, 700, 10);

Loading...