0xbeef.coffee

my website

Bitwise Bitmaps
March 26, 2017
This idea was given to me by an excersize in "The Art Of Computer Programming Volume 4 Fascicle 1" by Donald Knuth, which cited Clifford Pickover. Both of these authors I would highly recommend, even if you can't do a single excersize in any of Donald Knuth's books (I definately can't, but I learned much from that book.) The idea that was introduced to me was to take a 2d bitmap and color each pixel based on one bit of the output of an arbitrary function on the 2 integer coordinates of each pixel. The function that the problem uses was (X*X*Y), and it colored based on the 11th bit. I thought to get an idea of how this technique worked I would randomly generate a compatible function.
To do this I used a method best thought of as assembly instructions for a simple interpreter. The interpreter takes in a list of function pointers that define an instruction set. When a random program is generated, random instructions from the instruction set are chosen with random operands (either X or Y) to be evaluated for each pixel. This way, the user can define whatever instructions they want and see the patterns that arise. After each random instruction, the result is stored in an accumulator which is used as an operand for the next instruction. An advantage of this is that you can use high level instructions like bitwise reverse or iterate LFSR A on X Y times. Every program pictured is less than 30 instructions, and a couple are less than 5.

post4_1 post4_2 post4_3 post4_4 post4_5