 
 (defn get-transform-css [{rotation :Rotation, scale :Scale, pivot :PivotPoint, 
                           :or {rotation 0, scale 1, pivot {:x 0, :y 0}}}]
-  {html5TransformProperty (str "rotation(" rotation ") scale(" scale ")")
+  {html5TransformProperty (str "rotate(" (mod (/ (* rotation 180) js/Math.PI) 360) "deg) scale(" scale "," scale ")")
    html5TransformOriginProperty (str (:x pivot) "px " (:y pivot) "px")})
 
 (defn get-visibility-css [value]

    (om/update! ->owner :submorphs (conj submorphs morph))))

(defn remove-morph [->owner morph-id]
  (let [submorphs (get @->owner :submorphs)]
    (om/update! ->owner :submorphs (into [] (filter #(not= (% :id) morph-id) submorphs)))))

(defn set-rotation [->morph origin degrees]
  (om/update! ->morph :morph (-> (:morph @->morph) (assoc :Rotation degrees) (assoc :PivotPoint origin))))

(defn set-position [->morph pos]
  (om/update! ->morph [:morph :Position] pos))

(defmulti morph (fn [app owner] (get-in app [:morph :MorphClass])))

; utilities

(defn point-from-polar [radius angle]
  {:x (* radius (.cos js/Math angle)) :y (* radius (.sin js/Math angle))})

(defn add-points [point & points]
  (reduce (fn [p1 p2] {:x (+ (p1 :x) (p2 :x)) :y (+ (p1 :y) (p2 :y))}) point points))
