 (def base-font (Font. font-family font-style (float 100)))
 
 (def default-args
-  {:width 400
+  {:width 600
    :height 200
-   :precision 0.66
+   :precision 0.5
    :font base-font
-   :min-font-size 14
+   :min-font-size 13
    :max-font-size 60
-   :max-test-radius 250
-   :padding 4
+   :max-test-radius 350
+   :padding 2
+   :shape-mode :glyph-box ; :word-box, :glyph-box
+   :allow-rotation true
    })
-
-(defn- get-rect
-  [g font x]
-  (string-centered-rect g font (first x)))
 
 (defn- calc-font-size
   [{:keys [min-font-size max-font-size]} v]
   (float (+ min-font-size (* (- max-font-size min-font-size) v v))))
 
 (defn- get-font
-  [{:keys [font min-font-size max-font-size] :as args} x]
-  (.deriveFont font (calc-font-size args (second x))))
+  [{:keys [font] :as args} v]
+  (.deriveFont font (calc-font-size args v)))
 
 (defn- build-word-info
-  [g args w]
-  (let [text (first w)
-        font* (get-font args w)
-        rect (get-rect g font* w)]
-      {:text text :font font* :rect rect}))
+  [g args [text value]]
+  (let [font* (get-font args value)]
+    {:text text
+     :font font*
+     :word-bounds (string-centered-bounds g font* text)
+     :glyph-bounds (string-centered-glyphbounds g font* text)}))
 
 (defn- build-word-infos
   [word-stats & args]

(ns mastersign.wordcloud
  (:import [java.lang Math])
  (:import [java.awt Graphics Graphics2D Color RenderingHints Font])
  (:import [java.awt.geom Area
            Rectangle2D Rectangle2D$Float

  [g w h]
  (let [font (.deriveFont base-font (float 30.0))
        text "MjgqAIkqQ$§|"
        p1 (point 100 30)
        p2 (point 100 60)
        pc (point 200 150)
        r1 (string-centered-bounds g font text p1)
        r2 (string-centered-bounds g font text p2)
        a1 (Area. r1)
        c1 (rect-center r1)
        c2 (rect-center r2)]
    (doto g
      setup
      ;(draw-rect (rectangle 0 0 (dec w) (dec h)))
      ;(fill-rect r1)
      ;(draw-rect r1)
      ;(fill-rect r2)
      ;(draw-rect r2)
      ;(draw-string-centered text p1 :font font)
      ;(draw-string-centered text p2 :font font)
      ;(draw-dot c1)
      ;(draw-dot c2)

      (draw-dot pc)
      ;(draw-dots (test-ring 50 0.2) pc)
      ;(draw-dots (test-ring 10 0.2) pc)

      (draw-dots (test-sequence default-args {:text "Alpha"}) pc)
      )))

(let [img (create-image 400 300 test-painter)]
  (save-image img "D:/Temp/test.png"))

; ########################
