       (update-rgba)
       (update-color-record)
       (overlay-triangles)
-      (update-drawn-p-image)))
+      (update-drawn-p-image)
+      (update-previous-color-record)))
 
 (defn draw [state]
   (let [{:keys [p-image frame-mat]} state]

                       (keys triangle-points))]
    (assoc-in state [:color-record] colors)))

(defn draw-mosaic
  [tri-points tri-glyphs drawn-mat color-record [col row :as coords]]
  (let [[display-x display-y] (tri-points coords)
        c (color-record coords)]
    (cv-draw/draw-poly-with-pts drawn-mat c (tri-glyphs coords))))

(defn overlay-triangles
  [{:keys [drawn-mat rgba-mat triangle-points triangle-glyphs color-record] :as state}]
  (dorun
   (map (partial draw-mosaic
                 triangle-points
                 triangle-glyphs
                 drawn-mat
                 color-record)
        (keys triangle-points)))
  state)


(def ALPHA-STILL 255.0)

;; 32 works
(def NUM-COL-BINS 32.0)
(def DISPLAY-BIN-SIZE (/ DISPLAY-WIDTH NUM-COL-BINS))
(def NUM-ROW-BINS (/ DISPLAY-HEIGHT DISPLAY-BIN-SIZE))

