   (swap-state! current-state #(-> %
                                   (update :camera-x + dx)
                                   (update :camera-y + dy))))
+
+;; Math
+
+(def sqrt (.-sqrt js/Math))
+
+(defn dist-sq [x y]
+  (+ (* x x) (* y y)))
+
+(def dist (comp sqrt dist-sq))
+
+(defn vector-with-length [l x y]
+  (let [factor (/ l (dist x y))]
+    [(* factor x) (* factor y)]))
 
 ;; Layout
 

                         {:dx (- (.-x e1-center) (.-x e2-center))
                          :dy (- (.-y e1-center) (.-y e2-center))}))))))

(defn move-camera-on-pan! [current-state]
  (.subscribe
    (pan-deltas-observable (:svg @current-state))
    (fn [d] (let [{:keys [dx dy]} d] (move-camera! current-state dx dy)))))

;; Exported function to do magic



(def world-width 1280)
(def world-height 800)
(def update-interval-ms 15)
(def swipe-damping-factor 1)

;; SVG setup

