                   zoom-factor (get-in @app [:zoom-factor])
                   [doc-x doc-y] (geometry/screen-to-doc x y zoom-factor)
                   doc-width (get-in @app [:main-app :canvas-width])
+                  doc-height (get-in @app [:main-app :canvas-height])
                   paint-tool (get-in @app [:tools :paint-tool])]
 
                   (when (= event-type "mousedown")

      (let [current (first to-connect)
            connected (conj connected current)
            to-connect (disj to-connect current)
            candidates (set (neighborinos current image-data color))
            to-connect (sets/union to-connect (sets/difference candidates connected))]
        (recur connected to-connect)))))


(defn visit-pixels-for-fill-tool [doc-x doc-y image-data]
  (let [[orig-x orig-y] (get-in @guistate/transient-state [:mouse-down-pos])
        idx (geometry/flatten-to-index orig-x orig-y 64)
        color (nth image-data idx)
        fill-target (flood idx image-data color)]
    (doseq [i fill-target]
      (visit-pixel i))))


                            last-y ((get-in @guistate/transient-state [:mouse-down-pos]) 1)]
                        (visit-pixels-for-line-segment doc-x doc-y last-x last-y)))
                    (when (= paint-tool :fill)
                      (visit-pixels-for-fill-tool doc-x doc-y (get-in @app [:main-app :image-data]) doc-width doc-height))
                    (when (= paint-tool :picker)
                      (pick-color app doc-x doc-y doc-width))
                    (when (and (= paint-tool :selection) (not (om/get-state owner :user-is-moving-selection)))
