|
12345678910111213141516171819202122232425262728293031323334 |
- protocol Context {
- var itemsCount: Float { get }
- }
-
- protocol Position {
- var x: Float { get }
- var y: Float { get }
- }
-
- func memoryGap() -> Float {
- return memorySide() + memorySpace()
- }
-
- func memorySide() -> Float {
- return 50
- }
-
- func memorySpace() -> Float {
- return 20
- }
-
- func memoryItemPositions(c: Context) -> [Position] {
- var pos: [Position] = []
-
- let ids = Array.from(Array(c.itemsCount).keys());
- ids.forEach(i => {
- let row = Math.floor(i / 4)
- let x = memoryGap() + (i - row * 4) * memoryGap()
- let y = memoryGap() + row * memoryGap()
- // @ts-ignore
- pos.push(memoryCreatePosition(x, y))
- })
- return pos
- }
|