Михаил Капелько 1 anno fa
parent
commit
7f4e8bd09e
1 ha cambiato i file con 35 aggiunte e 12 eliminazioni
  1. +35
    -12
      web/memory.html

+ 35
- 12
web/memory.html Vedi File

@@ -5,6 +5,30 @@
</head>
<body>
</body>
<script>
function memorySide() {
return 50
}

function memorySpace() {
return 20
}

function memoryGap() {
return memorySide() + memorySpace()
}

function memoryItemPositions(M) {
var pos = [];
for (var i = 0; i < M.itemsCount; i++) {
let row = Math.floor(i / 4)
let x = memoryGap() + (i - row * 4) * memoryGap()
let y = memoryGap() + row * memoryGap()
pos.push([x, y])
}
return pos
}
</script>
<script>
var items = []

@@ -17,18 +41,17 @@
}

// SectionGrid.
let side = Number(50)
let space = Number(20)
let gap = Number(side + space)
for (var id in items) {
var item = items[id]
let row = Math.floor(id / 4)
let x = gap + (id - row * 4) * gap
let y = gap + row * gap
item.style.left = `${x}px`
item.style.top = `${y}px`
item.style.width = `${side}px`
item.style.height = `${side}px`
var M = {
itemsCount: items.length
};
let positions = memoryItemPositions(M);
for (var id in positions) {
var p = positions[id]
var item = items[id];
item.style.left = `${p[0]}px`
item.style.top = `${p[1]}px`
item.style.width = `${memorySide()}px`
item.style.height = `${memorySide()}px`
item.style.position = "absolute"
item.style.background = "blue"
}


Loading…
Annulla
Salva