Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Computer Graphics Exercises [3/9]

Exercise 2 output image

Connect each pair of discs by a line. Do not add another for loop, use just the given one.

Each line should span from one disc center to the other disc center.

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

Solution

for #i=40..720 +=50
	{	
	disc(i, 15, 10);
	disc(15, i, 10);
	line(i, 15, 15, i);
    sleepMs(100);
	}

(Note: the solution with line endpoints swapped is also correct.)

Loading...