At My Fingertips

Documentation

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

Decomposition

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...

Save in Toolbox

Now save your rounded_rectangle function in your toolbox. It should come in handy as a component for more complex graphics in the future.


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 c08406b (Wed, 20 Nov 2024 12:30:00 GMT)