I'm fascinated by this simple formula to create bit fields that look like alien art:

(x ^ y) % 9
Source:

<canvas id="c" width="1024" height="1024">
<script>
const context = c.getContext('2d');
for (let x = 0; x < 256; x++) {
for (let y = 0; y < 256; y++) {
if ((x ^ y) % 9) {
context.fillRect(x*4, y*4, 4, 4);
}
}
}
</script>
More examples:

(x ^ y) % 5
(x ^ y) % 17
(x ^ y) % 33

(inspired by )
If we use OR instead of XOR, we get some nice Sierpinski triangles:

(x | y) % 7
(x | y) % 17
(x | y) % 29
Circular patterns:

(x * y) & 64
(x * y) & 24
(x * y) & 47
Steps:

(x ^ y) < 77
(x ^ y) < 214
(x ^ y) < 120
Beams:

(x * 2) % y
(x * 64) % y
(x * 31) % y
This is just beautiful!

((x-128) * 64) % (y-128)
Checker:

(x ^ y) & 32
(x ^ y) & 72
(x ^ y) & 23
Noise:

((x * y) ** 4) % 7
((x * y) ** 5) % 99
((x * y) ** 9) % 3
Rotate:

(x % y) % 4
(y % x) % 20
40 % (x % y)
Minimal:

x & y
x % y
x & 9
You can also combine different patterns:

(x & y) & (x ^ y) % 19
((x ^ y) & 32) * (x ^ y) % 9)
(x * 64) % y * ((x ^ y) < 77)

• • •

Missing some Tweet in this thread? You can try to force a refresh

This Thread may be Removed Anytime!

Twitter may remove this content at anytime! Save it as PDF for later use!

# More from @aemkei

Nov 2, 2020
The most minimalist creative coding environment is alive:

tixy.land

Control the size and color of a 16x16 dot matrix with a single JavaScript function. The input is limited to 32 characters – but no limits to your creativity!

🔴🔴
🔴🔴
Some basic hints:

1. Click the dots to get detailed instructions.
2. Update the code to create your own animations.
3. Hit "submit" to save the code in the URL.