These are some small experiments with bitwise operations and trigonometric functions I made long time ago. The basic premise is that every pixel coordinate of the image,
(i, j), is evaluated on a loop based on a formula using either bitwise operations, trigonometric functions, or a mix of both. This combination gives emergence to some surprising and very interesting patterns!
// Mod operations are also to prevent values going over 255, // because the RGB range is [0, 255]. // (i, j) is every pixel coordinate in a loop. int x = (i % 255) + (j % 255); x %= 255; int r = x % 255; // Let's make use of the & bitwise operation. int g = (x & i) % 255; int b = (x & j) % 255; g.setColor(new Color(r, g, b)); g.drawRect(1024 - i,780 - j, 1, 1);
Here are some other interesting results:
This next one has some sort of a Moiré pattern, and also looks like a recursive or fractal structure. It has been feature in Paul Bourke’s wonderful fractal collection, and apparently different kind of mathematical methods give patterns very similar to this.
int x = (i * i) - (2 * (i | j)) + (j * j); x %= 255; x = Math.abs(x); g.setColor(new Color(x, x, x)); g.drawRect(i, j, 1, 1);
Now, some really crazy patterns, perhaps some day I’ll tell you how these are generated ;-)
Finally there’s these small tiles, which are just a part of a larger previously generated pattern. But there’s just something so special about these, I can’t tell exactly why, but it surprises me that such a pattern can emerge from purely mathematical operations.