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

27 lines
511B

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