At My Fingertips

Documentation

Hue Ring

Description

Implement the hue_ring method with parameters for the outer_radius and the inner_radius of the ring, to recreate the following graphic.

hue ring

The graphic is composed of 360 circular sectors appropriately rotated and colored. The color of each sector has a different hue (from 0 to 359), is fully saturated (saturation of 1.0) and fully light (value of 1.0), to achieve this you can use the pytamaro hsv_color function and the circular_sector function.

Note: in this activity we assume that you know how to use a for-loop. If you don't, try to do our hue-bar activity first, where we guide you a little bit through the implementation of a for-loop, and then come back when you are ready!

The hue_to_sector function

Let's now implement a hue_to_sector function to map from a hue to a sector.

This function should return a sector of the given radius with ideally angle of 1°, but for approximation reasons we suggest that you use an angle of 2°. The color of the sector depends on the value of the hue parameter: assert that it's a valid number from 0 to 360.

Loading...

The hue_ring function

This function takes the wanted outer_radius and inner_radius of the ring.

It produces 360 hue sectors corresponding to each hue value from 0 to 359, all pinned in the bottom left and rotated of 1° with respect to one another. Then it returns a Graphic with each sector composed together with the others. Ultimately, it should overlay a white inner circle on the final colored ring.

Use the pytamaro pin, compose, rotate and overlay functions.

You can use the pytamaro empty_graphic function.

To achieve this you can use a for-loop. In each step of the loop you want to create a sector of a different hue, pin it in the bottom left, rotate it accordingly and compose it together with the previous sectors.

Loading...

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

Hue Ring

Logo of PyTamaro

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

Privacy PolicyPlatform Version 1cd5229 (Tue, 05 Nov 2024 16:55:57 GMT)