mirror of
https://github.com/penpot/penpot.git
synced 2025-08-04 01:18:29 +02:00
✨ Select path nodes in area
This commit is contained in:
parent
bb719d6211
commit
a06a8c648e
8 changed files with 112 additions and 26 deletions
|
@ -253,3 +253,4 @@
|
|||
;; Intersection
|
||||
(d/export gin/overlaps?)
|
||||
(d/export gin/has-point?)
|
||||
(d/export gin/has-point-rect?)
|
||||
|
|
|
@ -285,6 +285,11 @@
|
|||
(or (not path?) (overlaps-path? shape rect))
|
||||
(or (not circle?) (overlaps-ellipse? shape rect))))))
|
||||
|
||||
(defn has-point-rect?
|
||||
[rect point]
|
||||
(let [lines (gpr/rect->lines rect)]
|
||||
(is-point-inside-evenodd? point lines)))
|
||||
|
||||
(defn has-point?
|
||||
"Check if the shape contains a point"
|
||||
[shape point]
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
(gpt/point (+ x width) (+ y height))
|
||||
(gpt/point x (+ y height))])
|
||||
|
||||
(defn rect->lines [{:keys [x y width height]}]
|
||||
[[(gpt/point x y) (gpt/point (+ x width) y)]
|
||||
[(gpt/point (+ x width) y) (gpt/point (+ x width) (+ y height))]
|
||||
[(gpt/point (+ x width) (+ y height)) (gpt/point x (+ y height))]
|
||||
[(gpt/point x (+ y height)) (gpt/point x y)]])
|
||||
|
||||
(defn points->rect
|
||||
[points]
|
||||
(let [minx (transduce gco/map-x-xf min ##Inf points)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue