The Joy of Programming
Combining Many Shapes

The + opeator could be used to combine two shapes into a single one.

What if we want to add multiple shapes togeter in one go?

The combine function

The combine function takes a list of shapes and combines all of the together into a single shape.

c1 = circle(r=50)
c2 = circle(r=100)
c3 = circle(r=150)

shape = combine([c1, c2, c3])
show(shape)

Combining a list of shapes into a single one is going to be very handy when start making more complex shapes and applying various transformations on them.

Exercise 4.3: Many Squares

Write a program to combine multiple squares as shown in the figure below into a single shape and show it.


Have a doubt?
Post it here, our mentors will help you out.