                   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")

;; Credits to:
;; http://stevelosh.com/blog/2012/10/caves-of-clojure-07-1/

(defn flood [idx image-data color]
  (loop [connected #{}
         to-connect #{idx}]
    (if (empty? to-connect)

;; =============================================================================
;; The Ned Flanders function

(defn neighborinos [idx image-data doc-width doc-height color]
  (let [left   (dec idx)
        right  (inc idx)
        top    (- idx doc-width)
        bottom (+ idx doc-width)
        result [left right top bottom]
        total-pixel-count (* doc-width doc-height)
        valid-result (filter #(and (>= % 0) (< % total-pixel-count)) result)]
    (filter #(= (nth image-data %) color) valid-result)))


