-
Notifications
You must be signed in to change notification settings - Fork 0
/
onebitp5.js
68 lines (45 loc) · 1.26 KB
/
onebitp5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
p5 = new P5()
p5.clear()
p5.background(0);
let mostCommonResult = calculateMostCommonResult();
for (let x = 0; x < p5.width; x += 2) {
for (let y=0; y<p5.height; y+=2) {
let result = calculateFunction(x, y);
if (result == mostCommonResult) {
p5.fill(0);
} else {
p5.fill(255);
}
p5.ellipse(x, y,2);
}
}
function calculateFunction(x, y) {
// return ((((x ^ y) | (~y)) % (~(x + 6))) & (~((x-1 / y) % (x / 10)))) % 3;
return ((((y + 4) & (x + y)) + ((~y) ^ (-y))) / ((-(y & 1)) + (~(y - x)))) % 4;
}
function calculateMostCommonResult() {
let counts = {};
for (let x = 0; x < width; x += 5) {
for (let y = 0; y < height; y += 5) {
let result = calculateFunction(x, y);
counts[result] = (counts[result] || 0) + 1;
}
}
let maxCount = 0;
let mostCommonResult;
for (let result in counts) {
if (counts[result] > maxCount) {
maxCount = counts[result];
mostCommonResult = result;
}
}
return parseInt(mostCommonResult);
}
p5.hide()
// To use P5 as an input to hydra, simply use the canvas as a source:
s0.init({src: p5.canvas})
// Then render the canvas
src(s0)
//.diff(src(s0).scale(0.98))
//.blend(o0)
.out()