       (.getContext "2d")))
 
 (defn draw-grid
-  [grid cell-size]
+  [grid]
   (let [ctx (get-ctx)
         width (count (first grid))
-        height (count grid)]
-    (.clearRect ctx 0 0 (* width cell-size) (* height cell-size))
+        height (count grid)
+        cell-width (/ canvas-width width)
+        cell-height (/ canvas-height height)]
+    (.clearRect ctx 0 0 canvas-width canvas-height)
 
     (set! (.-fillStyle ctx) "#CCC")
 


;; Constants

; TODO revisit *all* of these atoms
; consolidate them and reconcile them with this "visualization state" atom

(def cell-size 10)
(def grid-width 100)
(def grid-height 100)
(def canvas-height 800)
(def canvas-width 800)

(defonce selected-tab (r/atom :drunkard))
(defonce ms-per-tick (r/atom 16))

      :on-click (fn [e]
                  (.preventDefault e)
                  (condp = @selected-tab
                    :drunkard (draw-grid ((generate/drunkards-walk grid-width grid-height @num-empty-cells)
                                           ::generate/grid))
                    :automata (draw-automata-grid!)
                    :final (draw-grid ((generate/automata 400 400 0.45 4 5 400000 12)
                                        ::generate/grid))))}
     "generate"]]

   [:canvas {:id     "visualization-canvas"
             :width  canvas-width
             :height canvas-height
             :style  {:border           "none"
                      :background-color "#333"}}]])

;; Main

