     (q/fill stroke)
     (draw-ellipse pos [1 1] scale-fn)))
 
-(defn- draw-line [node parent scale-fn]
-  (let [node-color (get-in node [:meta :color])
-        parent-color (get-in node [:meta :color])
-        color (q/lerp-color node-color parent-color 0.5)
-        ]
-    (q/stroke color)
-    (q/stroke-weight 1)
-    (apply q/line (map scale-fn (map :pos (list parent node))))))
-
-(defn- draw-tree [forest parent node scale-fn]
-  "Draws the lines of all children leading from the node, recursively"
-  (draw-node node false scale-fn)
-  (let [children (map #(forest/get-node forest %) (:child-ids node))]
-    (doseq [child children] (draw-tree forest node child scale-fn))))
-
-(defn draw-dial [state dial posL posR]
-  (let [dial-norm (q/norm (:val dial) (:min dial) (:max dial))
-        dial-pos (map #(q/lerp %1 %2 dial-norm) posL posR)]
-    (q/stroke 0xFF000000)
-    (q/stroke-weight 1)
-    (q/fill   0xFF000000)
-    (apply q/line (concat posL posR))
-    (apply q/ellipse (concat dial-pos [5 5]))
-    ))
+(defn- clear-node [node bg-color scale-fn]
+  (let [pos (:pos node)]
+    (q/stroke bg-color)
+    (q/fill bg-color)
+    (draw-ellipse pos [1.5 1.5] scale-fn)))
 
 (defn draw-state [state]
   ; Clear the sketch by filling it with light-grey color.
-  (q/background (:background-color state))
   (q/with-translation window-half-size
 
     (let [grid-size (:grid-size state)
           scale-fn #(scale grid-size %)
-          ghost (:ghost state)
-          forest (:forest state)
-          roots (forest/roots forest)
           ]
 
-      (doseq [root roots]
-        (draw-tree forest nil root scale-fn))
-
-      (doseq [ghost (:ghosts state)]
-        (doseq [active-node (map #(forest/get-node forest %)
-                                 (:active-node-ids ghost))]
-          (draw-node active-node true scale-fn)))
+      (doseq [node (get-in state [:delta-state :rm-nodes])]
+        (clear-node node (:background-color state) scale-fn))
+
+      (doseq [node (get-in state [:delta-state :add-nodes])]
+        (draw-node node scale-fn))
 
       ))
-
-    ;(draw-dial state (:dial state) [30 30] [100 30])
-
-    ;(q/text (clojure.string/join
-    ;          "\n"
-    ;          (list
-    ;            (gstring/format "frame:%d" (:frame state))
-    ;            (gstring/format "second:%f" (curr-second state))
-    ;            (gstring/format "spawn-chance:%d" (spawn-chance state))))
-    ;        30 30)
   )
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defn setup []
  (let [state (new-state)]
    (q/color-mode :hsb 1 1 1)
    (q/frame-rate (:frame-rate state))
    (q/background (:background-color state))

  (q/sqrt (dist-from-sqr pos1 pos2)))

(defn take-adj-poss [grid-width pos adj-poss]
  (let [dist-from-center (dist-from-sqr [0 0] pos)
        width (* grid-width grid-width)
        dist-ratio (/ (- width dist-from-center) width)
        ]
    (take
      (int (* (q/map-range (rand) 0 1 0.1 1)
              dist-ratio
              (count adj-poss)))
      adj-poss)))
