mirror of
https://github.com/penpot/penpot.git
synced 2025-08-04 06:08:24 +02:00
⚡ Don't render not visible shapes on workspace
This commit is contained in:
parent
c667d3ad46
commit
ac4343dafd
8 changed files with 66 additions and 61 deletions
|
@ -275,21 +275,19 @@
|
|||
[a b]
|
||||
(mth/almost-zero? (- a b)))
|
||||
|
||||
;; FIXME: performance
|
||||
(defn overlaps-rects?
|
||||
"Check for two rects to overlap. Rects won't overlap only if
|
||||
one of them is fully to the left or the top"
|
||||
[rect-a rect-b]
|
||||
(let [x1a (dm/get-prop rect-a :x)
|
||||
y1a (dm/get-prop rect-a :y)
|
||||
x2a (+ x1a (dm/get-prop rect-a :width))
|
||||
y2a (+ y1a (dm/get-prop rect-a :height))
|
||||
|
||||
(let [x1a (:x rect-a)
|
||||
y1a (:y rect-a)
|
||||
x2a (+ (:x rect-a) (:width rect-a))
|
||||
y2a (+ (:y rect-a) (:height rect-a))
|
||||
|
||||
x1b (:x rect-b)
|
||||
y1b (:y rect-b)
|
||||
x2b (+ (:x rect-b) (:width rect-b))
|
||||
y2b (+ (:y rect-b) (:height rect-b))]
|
||||
x1b (dm/get-prop rect-b :x)
|
||||
y1b (dm/get-prop rect-b :y)
|
||||
x2b (+ x1b (dm/get-prop rect-b :width))
|
||||
y2b (+ y1b (dm/get-prop rect-b :height))]
|
||||
|
||||
(and (or (> x2a x1b) (s= x2a x1b))
|
||||
(or (>= x2b x1a) (s= x2b x1a))
|
||||
|
|
|
@ -307,12 +307,12 @@
|
|||
(defn overlaps?
|
||||
"General case to check for overlapping between shapes and a rectangle"
|
||||
[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)))]
|
||||
(let [swidth (/ (or (:stroke-width shape) 0) 2)
|
||||
rect (-> rect
|
||||
(update :x - swidth)
|
||||
(update :y - swidth)
|
||||
(update :width + (* 2 swidth))
|
||||
(update :height + (* 2 swidth)))]
|
||||
(or (not shape)
|
||||
(cond
|
||||
(cph/path-shape? shape)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue