Архитектурный шаблон "Мрак в моделях" на нескольких языках и платформах
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.

swift.swift 701B

11 mesi fa
11 mesi fa
11 mesi fa
11 mesi fa
11 mesi fa
11 mesi fa
11 mesi fa
11 mesi fa
123456789101112131415161718192021222324252627282930313233343536
  1. protocol Context {
  2. var itemsCount: Float { get }
  3. }
  4. protocol Position {
  5. var x: Float { get }
  6. var y: Float { get }
  7. }
  8. func memoryGap() -> Float {
  9. return memorySide() + memorySpace()
  10. }
  11. func memorySide() -> Float {
  12. return 50
  13. }
  14. func memorySpace() -> Float {
  15. return 20
  16. }
  17. func memoryItemPositions(c: Context) -> [Position] {
  18. var pos: [Position] = []
  19. // @ts-ignore
  20. let ids = utsIndexArray(c.itemsCount);
  21. ids.forEach(i => {
  22. // @ts-ignore
  23. let row = utsFloor(i / 4)
  24. let x = memoryGap() + (i - row * 4) * memoryGap()
  25. let y = memoryGap() + row * memoryGap()
  26. // @ts-ignore
  27. pos.push(memoryCreatePosition(x, y))
  28. })
  29. return pos
  30. }