-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern.js
More file actions
79 lines (70 loc) · 1.23 KB
/
Copy pathpattern.js
File metadata and controls
79 lines (70 loc) · 1.23 KB
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
69
70
71
72
73
74
75
76
77
// patterns
function pattern(x, y, style) {
let patterns = {
// Oscillators
blinker: [
[x, y - 1],
[x, y],
[x, y + 1]
],
toad: [
[x - 1, y],
[x, y],
[x + 1, y],
[x, y + 1],
[x + 1, y + 1],
[x + 2, y + 1]
],
beacon: [
[x, y],
[x + 1, y],
[x, y + 1],
[x + 1, y + 1],
[x + 2, y + 2],
[x + 3, y + 2],
[x + 2, y + 3],
[x + 3, y + 3]
],
// Still lifes
block: [
[x, y],
[x + 1, y],
[x, y + 1],
[x + 1, y + 1]
],
beehive: [
[x + 1, y],
[x + 2, y],
[x, y + 1],
[x + 3, y + 1],
[x + 1, y + 2],
[x + 2, y + 2]
],
// Spaceships
glider: [
[x + 1, y],
[x + 2, y + 1],
[x, y + 2],
[x + 1, y + 2],
[x + 2, y + 2]
],
lwss: [ // Lightweight spaceship
[x + 1, y],
[x + 2, y],
[x + 3, y],
[x + 4, y],
[x, y + 1],
[x + 4, y + 1],
[x + 4, y + 2],
[x, y + 3],
[x + 3, y + 3]
]
};
// return patterns[style]
let p = patterns[style]
// console.log(p)
p.forEach(coord => {
// console.log(coord)
grid.data[coord[0]][coord[1]].alive = true
})
}