 (ns identikon-cljs.core
   (:require
    [cljs-hash.goog :as gh]
-   [cljsjs.snapsvg]
+   [thi.ng.color.core :as col]
    [cljsjs.svgjs]))
 
 (enable-console-print!)
 
-;; define your app data so that it doesn't get over-written on reload
-
-(defn on-js-reload []
-  ;; optionally touch your app-state to force rerendering depending on
-  ;; your application
-  ;; (swap! app-state update-in [:__figwheel_counter] inc)
-  )
-
 (defn log-str
   ([x]   (do (.log js/console (pr-str x)) x))
   ([m x] (do (log-str {:msg m :data x})   x)))
-
-(log-str "hi" js/SVG)
 
 (defn sha1 [str]
   (gh/sha1-hex str))


(defn create-mirror [l]
  "Create a list of ints, break into chunks of 5 and convert those into mirrored chunks so that [0 1 2 3 4] becomes [0 1 2 1 0] and then flatten it all back out"
  (let [h (take 15 l)
        t (reverse (take 10 l))
        f (partition 5 (flatten (cons h t)))
        m (map #(flatten (cons (take 3 %) (reverse (take 2 %)))) f)]
    (flatten m)))

(defn convert-string [s]
  (-> s
      sha1
      to-pairs
      to-ints))

(defn get-svg [id]
  (let [d (.getElementById js/document id)
        w (.getAttribute d "width")
        h (.getAttribute d "height")
        p (js/SVG id)]
    (.spof p)
    (.attr p "width" w)

        xoffset (/ (* rwidth .1) 2) ; amount to offset the dots on x/y
        roffset (/ (* width .1) 12)
        cwidth (Math/floor (/ width amt)) ; circle width
        crad (- (* cwidth .85) roffset) ; circle radius
        cxs (mapv #(* cwidth %)
                  (drop 1 (take (+ 1 amt) (range)))) ; vector of x coords
        ]
