At My Fingertips
Rapid Playground
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
The images below give you a hint on how you could decompose the rounded rectangle
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.
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.
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
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version 0d7866a (Fri, 20 Dec 2024 07:46:38 GMT)