This commit is contained in:
Михаил Капелько
2023-06-05 19:28:23 +03:00
parent 19025d4c13
commit c50ee9aabb
7 changed files with 66 additions and 10 deletions

View File

@@ -1,11 +1,25 @@
// @ts-nocheck
func memoryItemPositions(c: Context) -> [Position] {
var pos = [Position]
protocol Context {
var itemsCount: Float { get }
}
class Position {
x: Float
y: Float
constructor(x, y) {
this.x = x
this.y = y
}
}
func memoryItemPositions(c: Context) -> Position[] {
var pos: Position[] = []
for (var i = 0; i < c.itemsCount; i++) {
let row = Math.floor(i / 4)
let x = memoryGap() + (i - row * 4) * memoryGap()
let y = memoryGap() + row * memoryGap()
pos.push(Position(x, y))
pos.push(new Position(x, y))
}
return pos
}