|
123456789101112131415161718192021222324252627282930313233343536 |
- 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] = []
-
- // @ts-ignore
- let ids = utsIndexArray(c.itemsCount);
- ids.forEach { i in
- // @ts-ignore
- let row = utsFloor(Float(i) / 4)
- let x = memoryGap() + (Float(i) - row * 4) * memoryGap()
- let y = memoryGap() + row * memoryGap()
- // @ts-ignore
- pos.append(memoryCreatePosition(x, y))
- }
- return pos
- }
|