Logiciel libre de géométrie, d'analyse et de simulation multiplateforme par Yves Biton

Accueil Tutoriels l’API de MathGraph32

Programming a figure en Python : the Sierpinski triangle

modification vendredi 23 avril 2024.

Toutes les versions de cet article : [English] [français]



Since 7.9.1 version, MathGraph32 API allows to create objects in a figure using Python language.

Here we will generate a fractal figure : the Sierpinski triangle.

If you modify the Python code, click on button Execute under the Python code edition window.
Line 24 sleep(1/100) decelerates the display to understand how the figure s constructed. The argument is given in seconds.
If you delete this line the figure will be generated almost instantly.

The figure we get is dynamical : You can move points A, B and C once the figure is constructed.