Let's look at how to draw rectangle and ellipse shapes. As you could have guessed, there are two new functions rectangle
and ellipse
.
s1 = rectangle()
s2 = ellipse()
show(s1, s2)
We could create a rectangle or an ellipse with different width and height by specifying the parameters w
and h
respectively.
s1 = rectangle(w=100, h=50)
s2 = ellipse(w=200, h=100)
show(s1, s2)
Both the rectangle and the ellipse are centered around the origin by default. Just like with the circle
, we can specify the center of the shape by specifying parameters x
and y
.
s1 = rectangle(x=0, y=-50, w=150, h=100)
s2 = ellipse(x=0, y=50, w=150, h=100)
show(s1, s2)
Draw a square of length 200 using the rectangle
function.
Draw two concentric squares around the origin with length 200 and 100 respectively.
Draw two rectangles as shown in the figure. Both the rectangles have sides as 100 and 200.
Draw two ellipses as shown in the figure.
Draw an eye as shown in the figure. Can you guess what are the dimensions?