0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-11 01:28:30 -05:00

🐛 Fix problem with booleans

This commit is contained in:
alonso.torres 2022-01-03 13:34:46 +01:00
parent 1ded4b2b28
commit 477f553675
2 changed files with 35 additions and 26 deletions

View file

@ -32,6 +32,7 @@
- After team onboarding importing a file will import into the team drafts [Taiga #2408](https://tree.taiga.io/project/penpot/issue/2408)
- Fix problem exporting shapes from handoff mode [Taiga #2386](https://tree.taiga.io/project/penpot/issue/2386)
- Fix lock/hide elements in context menu when multiples shapes selected [Taiga #2340](https://tree.taiga.io/project/penpot/issue/2340)
- Fix problem with booleans [Taiga #2356](https://tree.taiga.io/project/penpot/issue/2356)
### :arrow_up: Deps updates
### :heart: Community contributions by (Thank you!)

View file

@ -212,6 +212,27 @@
(d/seek overlap-single?)
(some?))))
(defn fix-move-to
[content]
;; Remove the field `:prev` and makes the necessaries `move-to`
;; then clean the subpaths
(loop [current (first content)
content (rest content)
prev nil
result []]
(if (nil? current)
result
(let [result (if (not= (:prev current) prev)
(conj result (upc/make-move-to (:prev current)))
result)]
(recur (first content)
(rest content)
(gsp/command->point current)
(conj result (dissoc current :prev)))))))
(defn create-union [content-a content-a-split content-b content-b-split sr-a sr-b]
;; Pick all segments in content-a that are not inside content-b
;; Pick all segments in content-b that are not inside content-a
@ -225,7 +246,7 @@
content-geom (gsp/content->geom-data content)
content-sr (gsp/content->selrect content)
content-sr (gsp/content->selrect (fix-move-to content))
;; Overlapping segments should be added when they are part of the border
border-content
@ -263,38 +284,25 @@
(defn create-exclusion [content-a content-b]
;; Pick all segments
(d/concat-vec content-a content-b))
(defn fix-move-to
[content]
;; Remove the field `:prev` and makes the necessaries `move-to`
;; then clean the subpaths
(loop [current (first content)
content (rest content)
prev nil
result []]
(if (nil? current)
result
(let [result (if (not= (:prev current) prev)
(conj result (upc/make-move-to (:prev current)))
result)]
(recur (first content)
(rest content)
(gsp/command->point current)
(conj result (dissoc current :prev)))))))
(let []
(d/concat-vec content-a content-b)))
(defn content-bool-pair
[bool-type content-a content-b]
(let [content-a (-> content-a (close-paths) (add-previous))
(let [;; We need to reverse the second path when making a difference/intersection/exclude
;; and both shapes are in the same direction
should-reverse? (and (not= :union bool-type)
(= (ups/clockwise? content-b)
(ups/clockwise? content-a)))
content-a (-> content-a
(close-paths)
(add-previous))
content-b (-> content-b
(close-paths)
(cond-> (ups/clockwise? content-b)
(ups/reverse-content))
(cond-> should-reverse? (ups/reverse-content))
(add-previous))
sr-a (gsp/content->selrect content-a)