package snake package life import LifeModel.* /** m13 life view: live cells as squares, and a status strip under the board. */ object LifeView: private val W = LW * LCELL private val H = LH * LCELL private def text(x: Int, y: Int, str: String, align: String): Shape = Shape.Text(x, y, str, "#ffffff", 14, align) def lifeView(state: LifeState): Scene = Shape.Rect(0, 0, W, H, "#111111") :: state.cells.map(p => Shape.Rect(p.x * LCELL + 1, p.y * LCELL + 1, LCELL - 2, LCELL - 2, "#7cb342")) ++ List( Shape.Rect(0, H, W, STRIP, "#222222"), text(6, H + 17, s"Generation ${state.generation}", "left"), text(W - 6, H + 17, if state.running then "Running: Space pauses" else "Paused: Space runs, N steps", "right") )