   "Check if a shape is contained in the
   provided selection rect."
   [shape selrect]
-  (let [sx1 (:x selrect)
-        sx2 (+ sx1 (:width selrect))
-        sy1 (:y selrect)
-        sy2 (+ sy1 (:height selrect))
-        rx1 (:x shape)
-        rx2 (+ rx1 (:width shape))
-        ry1 (:y shape)
-        ry2 (+ ry1 (:height shape))]
-    (and (neg? (- (:y selrect) (:y shape)))
-         (neg? (- (:x selrect) (:x shape)))
-         (pos? (- (+ (:y selrect)
-                     (:height selrect))
-                  (+ (:y shape)
-                     (:height shape))))
-         (pos? (- (+ (:x selrect)
-                     (:width selrect))
-                  (+ (:x shape)
-                     (:width shape)))))))
-
-;; TODO: maybe remove, seems it not used anymore.
-
-(defn translate-coords
-  "Given a shape and initial coords, transform
-  it mapping its coords to new provided initial coords."
-  ([shape x y]
-   (translate-coords shape x y -))
-  ([shape x y op]
-   (let [x' (:x shape)
-         y' (:y shape)]
-     (assoc shape :x (op x' x) :y (op y' y)))))
-
-;; This function will be deleted when selrect is implemented properly
-
-(defn parent-satisfies?
-  "Resolve the first parent that satisfies a condition."
-  [{:keys [group] :as shape} pred]
-  (let [shapes-by-id (:shapes @st/state)]
-    (if group
-      (loop [parent (get shapes-by-id group)]
-        (cond
-          (pred parent) true
-          (:group parent) (recur (get shapes-by-id (:group parent)))
-          :else false))
-      false)))
+  (let [{sx1 :x1 sx2 :x2 sy1 :y1 sy2 :y2} selrect
+        {rx1 :x1 rx2 :x2 ry1 :y1 ry2 :y2} shape]
+    (and (neg? (- sy1 ry1))
+         (neg? (- sx1 rx1))
+         (pos? (- sy2 ry2))
+         (pos? (- sx2 rx2)))))

;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>

(ns uxbox.main.geom
  (:require [uxbox.util.geom.matrix :as gmt]
            [uxbox.util.geom.point :as gpt]
            [uxbox.util.math :as mth]
            [uxbox.store :as st]))

;; --- Relative Movement

;; TODO: revisit, maybe dead code
(declare move-rect)
(declare move-path)
(declare move-circle)

      :y1 miny
      :x2 maxx
      :y2 maxy
      :type :rect})))

(defn- group->rect-shape
  [state {:keys [id items rotation] :as group}]
  (let [shapes (map #(get-in state [:shapes %]) items)]
    (-> (shapes->rect-shape state shapes)
        (assoc :rotation rotation)
        (assoc :id id))))

(defn- path->rect-shape
  [state {:keys [points] :as shape}]
