At My Fingertips

Rounded Rectangle

In this activity we will implement the rounded_rectangle function that generates a rounded rectangle of the given width and height and with the given corner_radius, like the following ones

rectangles

Decomposing the rectangle

The images below give you a hint on how you could decompose the rounded rectangle

decomposed rectangle

The edge

Start by implementing the rounded_edge function that generates the top edge of a rounded rectangle, with corners of the given corner_radius and total width of the given width.

Use the pytamaro functions rectangle, circular_sector and beside.

If needed, you can also use the rotate function.

Loading...

The rounded rectangle

Now you're ready to implement the rounded_rectangle function! Remember that the given width and height should be the total width and height of the rectangle.

Use the rounded_edge function you just implemented and the pytamaro functions rectangle, rotate and above.

Loading...

This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.

Rounded Rectangle

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version b744b47 (Tue, 08 Oct 2024 16:30:14 GMT)