Архитектурный шаблон "Мрак в моделях" на нескольких языках и платформах
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 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
- }
|