Jonathan. Frech’s WebBlog

Menger Sponge II (#143)

Jonathan Frech

In July of 2015 I published my Menger Sponge post. As I said there, the true Menger Sponge is a three-di­men­sion­al object, but due to the lack of 3D-integration in Pygame, I on­ly showed one of the six cube’s faces. The two-di­men­sion­al fractal is officially called Sierpiński carpet while the three-di­men­sion­al object is really called a Menger sponge.
To achieve the three-di­men­sion­al cube, I used Processing 3 together with its Python Mode.
The actual fractal is colored with a pseudo-ran­dom­ly 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

Source code: menger-sponge-ii.pyde