   (aset overlay-canvas "height"(.-innerHeight js/window)))
 
 (defn render-mandelbrot!
-  [{:keys [scale x0 y0 escape-radius] :as render-state}]
+  [{escape-radius                          :escape-radius
+    {:keys [scale x0 y0] :as render-state} :rendering-data}]
 
   (println render-state)
 

(def overlay-context (.getContext overlay-canvas "2d"))

(def initial-rendering-data
  {:escape-radius  10000
   :scale          350 ; How many pixels a distance of 1 in the complex plane takes up
   :x0             -3
   :y0             1.2})

(defonce app-state (atom {:rendering-data initial-rendering-data}))

(defn reset-rendering-data!
  "Resets the rendering data to the original (i.e. reset the zoom)


    (.log js/console "Done in: " (int (* 1000 (/ (* height width)  (- (.getTime (js/Date.)) start)))) "px/s")))

(set! (.-onresize js/window) (fn [] (render-mandelbrot! @app-state)))

(add-watch app-state :state-changed
           (fn [_ _ old-state new-state]
             (when-not (= (:rendering-data old-state)
                          (:rendering-data new-state))
               (render-mandelbrot! new-state))))

(defn add-overlay-rectangle!
  "Adds a rectangle to the overlay canvas (and optionally clears all other rectangles)"
