jblog
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

Microcounter

2016-09-24, post № 142

MicroPython, programming, Python 3, #micro, #microcontroller, #pyboard

Being a big fan of Python [1], I recently got a MicroPython Board.
MicroPython is a simple to use micro controller which runs Python 3. To put code onto it, you simple mount it as you would do with a USB flash drive, copy your main.py to it and restart your MicroPython.
As a simple “Hello world.”-program, I wrote this counting script. Every time you press the built-in [2] button, it counts up by one. Using the four built-in LEDs and binary number representation, this counter can count from 𝟢 to 𝟣𝟧 and then wraps back.

microcounter.gif
Source code: microcounter.py

J-Trix

2016-09-10, post № 141

curses, programming, Python, #animation, #bit, #bits, #falling bits, #hacker, #hacking, #Matrix, #screensaver

Recreating the famous falling bit effect from Matrix using python and curses.The individual bit strips are separate entities, falling to the bottom and then being moved up again with a different 𝑥 value. They also get a random speed between one and five deciseconds.

j-trix.gif
Source code: j-trix.py
Jonathan Frech's blog; built 2021/04/16 20:21:20 CEST