At My Fingertips

Compose a graphic of a sliced kiwi fruit.

In our graphic, the small seeds of the kiwi are distributed in two rings.
They are dark (the color is already defined in `SEED_COLOR`

)
and have an elliptical shape (about 2/3 as wide as long).

Implement the `kiwi_seed`

function.
Use ellipse.

Loading...

Compose a sliced kiwi without any seeds and without the core.
Use the given colors for the brownish skin (`SKIN_COLOR`

),
and the greenish flesh (`FLESH_COLOR`

).
The kiwi should have the given overall `diameter`

and the flesh should be 95% of that diameter.

Loading...

Create a function `ring`

that produces a ring of `count`

seeds, evenly spread across the 360 degrees of a circle.
The inside diameter of the ring should correspond to `diameter`

(the seeds should form a ring just outside the diameter).
Repetitively call `kiwi_seed`

to produce the ring of seeds.

Hint: If you need help, check out the **Sliced Pitaya** activity.

Loading...

The inside of a kiwi, around the seeds, is slightly darker. We can compose this darker area using two rings of triangles.

Each ring consists of isoceles triangles with the given side length and a 20 degree angle.

Before creating a ring, implement the `kiwi_triangle`

function to construct a single triangle.

Loading...

**Insight**:
To create a ring of triangles we can use the `ring`

function we originally wrote to create seed rings. It doesn't really matter what graphic we repeat in the ring: a seed, or a triangle, or anything else! This is great **code reuse**!

Here is a ring consisting of 12 triangles, with a ring diameter of 50 and a triangle side length of 25:

Loading...

Now we have all the ingredients for our sliced kiwi.
The kiwi consists of the `sliced_kiwi_base`

, two `ring`

s of `kiwi_triangle`

s, two `ring`

s of `kiwi_seed`

s, and a core circle.

Each seed ring is composed of 24 seeds, with a seed diameter of 5% of the kiwi diameter:

- ring diameter: 30% of kiwi diameter
- ring diameter: 45% of kiwi diameter

Each triangle ring is composed of 12 triangles and has a ring diameter of 25% of the kiwi's diameter:

- side 20% of the kiwi's diameter, rotated by 1/24 a triangle's angle
- side 25% of the kiwi's diameter

Place all rings on top of the kiwi base, and place a core circle (with 25% of the kiwi diameter) on top.

Loading...

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

Sliced Kiwi

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

Privacy Policy • Platform Version b744b47 (Tue, 08 Oct 2024 16:30:14 GMT)