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

26 lines
485B

  1. protocol Context {
  2. var itemsCount: Float { get }
  3. }
  4. class Position {
  5. x: Float
  6. y: Float
  7. constructor(x, y) {
  8. this.x = x
  9. this.y = y
  10. }
  11. }
  12. func memoryItemPositions(c: Context) -> Position[] {
  13. var pos: Position[] = []
  14. for (var i = 0; i < c.itemsCount; i++) {
  15. let row = Math.floor(i / 4)
  16. let x = memoryGap() + (i - row * 4) * memoryGap()
  17. let y = memoryGap() + row * memoryGap()
  18. pos.push(new Position(x, y))
  19. }
  20. return pos
  21. }