diff --git a/CHANGES.md b/CHANGES.md index b894c61543..3458549410 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,7 @@ - Fix problem duplicating paths [Taiga #2147](https://tree.taiga.io/project/penpot/issue/2147) - Fix problem inheriting attributes from SVG root when importing [Taiga #2124](https://tree.taiga.io/project/penpot/issue/2124) - Fix problem with lines and inside/outside stroke [Taiga #2146](https://tree.taiga.io/project/penpot/issue/2146) +- Add stroke width in selection calculation [Taiga #2146](https://tree.taiga.io/project/penpot/issue/2146) ### :arrow_up: Deps updates ### :boom: Breaking changes diff --git a/common/src/app/common/geom/shapes/intersect.cljc b/common/src/app/common/geom/shapes/intersect.cljc index 796daf0997..3cc3589652 100644 --- a/common/src/app/common/geom/shapes/intersect.cljc +++ b/common/src/app/common/geom/shapes/intersect.cljc @@ -284,12 +284,19 @@ (defn overlaps? "General case to check for overlaping between shapes and a rectangle" [shape rect] - (or (not shape) - (let [path? (= :path (:type shape)) - circle? (= :circle (:type shape))] - (and (overlaps-rect-points? rect (:points shape)) - (or (not path?) (overlaps-path? shape rect)) - (or (not circle?) (overlaps-ellipse? shape rect)))))) + (let [stroke-width (/ (or (:stroke-width shape) 0) 2) + rect (-> rect + (update :x - stroke-width) + (update :y - stroke-width) + (update :width + (* 2 stroke-width)) + (update :height + (* 2 stroke-width)) + )] + (or (not shape) + (let [path? (= :path (:type shape)) + circle? (= :circle (:type shape))] + (and (overlaps-rect-points? rect (:points shape)) + (or (not path?) (overlaps-path? shape rect)) + (or (not circle?) (overlaps-ellipse? shape rect))))))) (defn has-point-rect? [rect point]