mirror of
https://github.com/penpot/penpot.git
synced 2025-07-15 01:27:16 +02:00
🐛 Fix incorrect type handling on path join nodes operation
This commit is contained in:
parent
c5b0206bf0
commit
a772b442c8
1 changed files with 24 additions and 13 deletions
|
@ -628,27 +628,38 @@
|
|||
(rest content))))))))
|
||||
|
||||
(defn join-nodes
|
||||
"Creates new segments between points that weren't previously"
|
||||
"Creates new segments between points that weren't previously.
|
||||
Returns plain segments vector."
|
||||
[content points]
|
||||
|
||||
(let [segments-set (into #{}
|
||||
(map (juxt :start :end))
|
||||
(get-segments-with-points content points))
|
||||
(let [;; Materialize the content to a vector (plain format)
|
||||
content
|
||||
(vec content)
|
||||
|
||||
create-line-command (fn [point other]
|
||||
[(helpers/make-move-to point)
|
||||
(helpers/make-line-to other)])
|
||||
segments-set
|
||||
(into #{}
|
||||
(map (juxt :start :end))
|
||||
(get-segments-with-points content points))
|
||||
|
||||
not-segment? (fn [point other] (and (not (contains? segments-set [point other]))
|
||||
(not (contains? segments-set [other point]))))
|
||||
create-line-segment
|
||||
(fn [point other]
|
||||
[(helpers/make-move-to point)
|
||||
(helpers/make-line-to other)])
|
||||
|
||||
new-content (->> (d/map-perm create-line-command not-segment? points)
|
||||
(flatten)
|
||||
(into []))]
|
||||
not-segment?
|
||||
(fn [point other]
|
||||
(and (not (contains? segments-set [point other]))
|
||||
(not (contains? segments-set [other point]))))
|
||||
|
||||
;; FIXME: implement map-perm in terms of transducer, will
|
||||
;; improve performance and remove the need to use flatten
|
||||
new-content
|
||||
(->> (d/map-perm create-line-segment not-segment? points)
|
||||
(flatten)
|
||||
(into []))]
|
||||
|
||||
(into content new-content)))
|
||||
|
||||
|
||||
(defn separate-nodes
|
||||
"Removes the segments between the points given"
|
||||
[content points]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue