At My Fingertips

Documentation

Color Flower

Your challenge: compose a flower with rainbow-colored leaves.

The function hsl_color is a great way to create all the colors of a rainbow.

Each leaf of your flower should have a different color. The tone of the color conveniently corresponds to the angle of the leaf: 0 is red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, and 300 is magenta.

Tip: If you use a semi-transparent color (opacity around 0.5) the leaves will be partially see-through, and you will be able to see the underlying leaves.

Create a Leaf

Implement the given function leaf. Pin the leaf center-left and rotate it by the given angle.

leaf

Loading...

Compose a Flower from Leaves

Implement the flower function so that it constructs a 12-leaved colorful flower.

flower

Use the function leaf to construct the leaves. Use the function compose to compose two leaves into one graphic. The function empty_graphic can help to reduce an arbitrary number of leaves into a single graphic.

Loading...

Special Flowers

Which colors do you get when you construct a flower with only 3 leaves?

Can you construct a flower with 3 leaves with angles (not starting with 0 degrees) such that the leaves are yellow, cyan, and magenta?

What happens if you construct a flower with 360 leaves?


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

Color Flower

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)