This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Panel which will draw a grid of cells as either On or Off according to a given function. | |
*/ | |
class OnOffGrid(val cellsX: Int, val cellsY: Int, cellWidth: Int = 20, cellHeight: Int = 20) extends Panel with Publishe | |
r { | |
preferredSize = new Dimension(cellsX * cellWidth, cellsY * cellHeight) | |
listenTo(mouse.clicks) | |
reactions += { | |
case MouseClicked(_, point, _, _, _) => publish(CellClicked(this, point.x / cellWidth, point.y / cellHeight)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object GofUI extends SimpleSwingApplication { | |
val grid = new OnOffGrid(20, 20) { | |
onOff = gridCellIsLive | |
} | |
val tickButton = new Button { | |
text = "Tick" | |
} | |
def top = new MainFrame { | |
title = "Game of Life" |