-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
66 lines (53 loc) · 1.47 KB
/
Copy pathfunction.js
File metadata and controls
66 lines (53 loc) · 1.47 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
'use strict';
module.exports = live_surround;
module.exports = block_seat;
module.exports =
module.exports =
module.exports =
module.exports =
module.exports =
module.exports =
module.exports =
module.exports =
// ブロックを敷き詰めるループ
function block_seat(containerWidth,containerHeight,blockWidth,blockHeight){
for (let y = 0; y < containerHeight; y += blockHeight) {
for (let x = 0; x < containerWidth; x += blockWidth) {
// ブロック要素を作成
const block = document.createElement('div');
block.classList.add("block");
// ブロックの位置を設定
block.style.left = x + 'px';
block.style.top = y + 'px';
// コンテナにブロックを追加
container.appendChild(block);
}
}
return
}
function live_surround(livelist,WidthblockNum){
let num =WidthblockNum;
let surround =[];
for (let i = 0; i<livelist.length; i++){
//現在生きてるマス(livelist)
let livnum = livelist[i];
//左上
let lefup = livnum - (num + 1);
//中央上
let cenup = livnum - num;
//右上
let rigup = livnum - (num - 1);
//左隣
let lefs = livnum - 1;
//右隣
let rigs = livnum + 1;
//左下
let lefd = livnum + (num -1);
//中央下
let cend = livnum + (num);
//右下
let rigd = livnum + (num + 1);
surround.push(lefup,cenup,rigup,lefs,livnum,rigs,lefd,cend,rigd);
}
return surround;
}