Архитектурный шаблон "Мрак в моделях" на нескольких языках и платформах
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

25 lignes
484B

  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. }