                       :dashes [20 3 10 3 5 3]
                       :cap :butt
                       :join :bevel
-                      :miter-limit 10.0}}}
-   {:type :primitive-text
-    :params {:x 180 :y 120 :text "TEST"
+                      :miter-limit 10.0}}]
+   [:primitive-text
+    {:x 180 :y 120 :text "TEST"
              :color Color/BLUE
              :alpha 0.5
              :font {:name "Arial"


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

(defn paint-canvas-graphics [^Graphics graphics data]
  (draw-primitives graphics data))


;; 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}]
