hp
toc

Koch Snowflake

2016-04-30, post № 121

mathematics, programming, Pygame, Python, #animated fractal, #flake, #fractal, #fractal generating, #fractal gif, #generate

In my collection of programs generating fractals this famous one cannot miss.
The Koch snowflake is generated by starting with an equilateral triangle. Every side of the triangle then gets cut into three equal pieces and the center one gets replaced with yet another equilateral triangle.
To get the perfect fractal, you would need to repeat this process infinitely many times.
More information on the snowflake can be found in this Wikipedia entry.

Controls

  • ‘F1’ iterates the fractal,
  • ‘F2’ zooms in,
  • ‘F3’ zooms out,
  • ‘F4’ resets zoom,
  • ‘F5’ takes a screenshot,
  • Arrow keys move the camera around.
koch-snowflake.gif
Source code: koch-snowflake.py
Jonathan Frech's blog; built 2024/12/19 23:13:08 CET