 
 (defn draw-primitives [g2d items]
   (enable-anti-aliasing g2d)
-  (dorun
-    (for [item (flatten items)]
-      (let [params (:params item)]
-      (set-style g2d params)
-      (draw-primitive g2d (:type item) (complete-coordinates params))))))
+  (doseq [[type params inner] items]
+    (println type params inner)
+    (set-style g2d params)
+    (draw-primitive g2d type (complete-coordinates params))
+    ))
 
 (defn paint-canvas-graphics [^Graphics graphics data]
   (draw-primitives graphics data))

                    :italic false
                    :underline true
                    :strikethrough false
                    :size 100}}}
   {:type :primitive-line
    :params {:x 180 :y 120 :w 0 :h 150 :color Color/RED
             :stroke {:width 10 :cap :round}
             :alpha 0.7}}
   {:type :primitive-line
    :params {:x 180 :y 120 :w 30 :h 0 :color Color/GREEN
             :alpha 0.6
             :stroke {:width 4}}}
   {:type :primitive-arc
    :params {:l 40 :t 30 :w 100 :h 100
             :start-angle 10 :arc-angle 100 :color Color/GREEN
             :filled true}}
   ])

(def grafix (atom temp-data))

(defn canvas-frame [reference]
  (let [panel (canvas reference)]
    (doto (JFrame. "canvas")
      (.. getContentPane (add panel))
      (.setBounds 10 10 500 500)
      .show)
    panel))

(defn demo-var []
  (canvas-frame (var temp-data)))

(defn demo-atom []
  (canvas-frame grafix))

(defn demo-animation [reference]
  (dotimes [i 200]
  (Thread/sleep 30)
  (swap! reference (fn [data]
                     (-> data
                         (assoc-in [0 :params :w] (+ i 100))
                         (assoc-in [0 :params :h] (+ i 100)))
                     ))))



;; test

(def grafix (atom nil))

(defn canvas-frame [reference]
  (let [panel (canvas reference)]
    (doto (JFrame. "canvas")
      (.. getContentPane (add panel))
      (.setBounds 10 10 500 500)
      .show)
    panel))

(defn demo-atom []
  (canvas-frame grafix))

(defn demo-animation [reference]
  (dotimes [i 200]
  (Thread/sleep 30)
  (swap! reference (fn [data]
                     (-> data
                         (assoc-in [0 :params :w] (+ i 100))
                         (assoc-in [0 :params :h] (+ i 100)))
                     ))))

(reset! grafix 
  [
   [:primitive-round-rect
    {:l 20 :t 10 :w 300 :h 300
             :arc-radius 50
             :filled true :color Color/PINK}]
   [:primitive-ellipse
    {:l 25 :t 15 :w 110 :h 90
             :filled true :color Color/YELLOW}]
   [:primitive-round-rect
    {:l 20 :t 10 :w 300 :h 300
             :arc-width 50 :arc-height 50
             :filled false :color Color/DARK_GRAY
             :stroke {:width 5
                      :dashes [10 10] :dash-phase 0}}]
   [:primitive-polygon
    {:vertices [{:x 100 :y 100}
                        {:x 50 :y 150}
                        {:x 50 :y 220}
                        {:x 160 :y 250}]
