Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Simple Graphics [13/14]

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

To accomplish the movemement leftward, a subtraction operation was performed in the third argument of the line function 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 function calls have to use the same coordinates as given in the the line function call.

Hint 2

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

The line function 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...