var width; var height; var cellSize; var cellCount; var grid; var ctx; var canvas; var OFF = 0; var ON = 1; var DYING = 2; var isDrawing = false; function mouseClickChange() { isDrawing = !isDrawing; } function mouseMove(e){ if (isDrawing) { var x = Math.floor((e.clientX - canvas[0].offsetLeft) / cellSize); var y = Math.floor((e.clientY - canvas[0].offsetTop) / cellSize); cycle(x,y); drawGrid(); } } function init(cvs) { canvas = cvs; width = canvas.width(); height = canvas.height(); ctx = canvas[0].getContext("2d"); cellSize = 10; cellCount = Math.min(width,height) / cellSize; grid = new Array(cellCount); for (i=0;i