hp
toc

Menger Sponge II

2016-10-08, post № 143

Processing 3, programming, Python, #3D, #fractal, #three dimensions, #three-D, #three-dimensional

In July of 2015 I published my Menger Sponge post. As I said there, the true Menger Sponge is a three-dimensional object, but due to the lack of 3D-integration in Pygame, I only showed one of the six cube’s faces. The two-dimensional fractal is officially called Sierpiński carpet while the three-dimensional object is really called a Menger sponge.
To achieve the three-dimensional cube, I used Processing 3 together with its Python Mode.
The actual fractal is colored with a pseudo-randomly chosen color. All its smaller cubes then get a slight color shift. The cube rotates slowly, with a different speed on each of the three axes.

Controls

  • ‘Space’will advance the cube’s fractalness,
  • ‘q’ will save an image of the current fractal’s state.
menger-sponge-ii-0.png
menger-sponge-ii-1.png
menger-sponge-ii-2.png
menger-sponge-ii-3.png
menger-sponge-ii-4.png
Source code: menger-sponge-ii.pyde
Jonathan Frech's blog; built 2024/08/31 22:59:44 CEST