   (om/set-state! owner :user-is-moving-selection false))
 
 
-(defn make-selection [app owner doc-x doc-y]
+(defn make-selection [app owner doc-x doc-y doc-width]
   (let [[orig-x orig-y] (get-in @guistate/transient-state [:mouse-down-pos])
         selection-rect (geometry/normalize-rect orig-x orig-y doc-x doc-y)
         main-image (get-in @app [:main-app :image-data])]
     (om/set-state! owner :selection selection-rect)
-    (om/set-state! owner :selection-image (clip-sub-image main-image selection-rect))))
+    (om/set-state! owner :selection-image (clip-sub-image main-image selection-rect doc-width))))
 
 
 (defn draw-selection [app owner]

        (.fillRect context x-with-offset y-with-offset pixel-size pixel-size)))))


(defn clip-sub-image [image rect]
  (let [[x1 y1 x2 y2] rect
        width (geometry/rect-width rect)
        height (geometry/rect-height rect)
        main-image-width 64
        sub-image-indices(for [y (range y1 y2)
                               x (range x1 x2)
                               :let [i (geometry/flatten-to-index x y main-image-width)]]
                               i)
        sub-image-data (vec (map #(nth image %) sub-image-indices))]
      {:width width

                    (when (= paint-tool :picker)
                      (pick-color app doc-x doc-y doc-width))
                    (when (and (= paint-tool :selection) (not (om/get-state owner :user-is-moving-selection)))
                      (make-selection app owner doc-x doc-y doc-width))
                    (when (and (= paint-tool :selection) (om/get-state owner :user-is-moving-selection))
                      (let [[xOff yOff] (om/get-state owner :mouse-offset-in-selection)
                            [x1 y1 x2 y2] (om/get-state owner :selection)
