At My Fingertips

Documentation

Sliced Kiwi

Compose a graphic of a sliced kiwi fruit.

Sliced Kiwi

Kiwi Seed

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

Sliced Kiwi Base

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

Ring of Seeds

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

Ring of Triangles

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

Sliced Kiwi

Now we have all the ingredients for our sliced kiwi. The kiwi consists of the sliced_kiwi_base, two rings of kiwi_triangles, two rings of kiwi_seeds, 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

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)