Select path nodes in area

This commit is contained in:
alonso.torres 2021-03-30 17:13:05 +02:00 committed by Andrés Moya
parent bb719d6211
commit a06a8c648e
8 changed files with 112 additions and 26 deletions

View file

@ -253,3 +253,4 @@
;; Intersection
(d/export gin/overlaps?)
(d/export gin/has-point?)
(d/export gin/has-point-rect?)

View file

@ -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]

View file

@ -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)