0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-10 06:41:40 -05:00

🐛 Fix problem with new nodes in paths

This commit is contained in:
alonso.torres 2021-05-26 10:41:12 +02:00 committed by Andrey Antukh
parent bd8aa8163d
commit 6d0b36e9b9
2 changed files with 20 additions and 13 deletions

View file

@ -36,6 +36,7 @@
- Fix issue when group creation leaves an empty group [#1724](https://tree.taiga.io/project/penpot/issue/1724) - Fix issue when group creation leaves an empty group [#1724](https://tree.taiga.io/project/penpot/issue/1724)
- Fix problem with :multiple for colors and typographies [#1668](https://tree.taiga.io/project/penpot/issue/1668) - Fix problem with :multiple for colors and typographies [#1668](https://tree.taiga.io/project/penpot/issue/1668)
- Fix problem with locked shapes when change parents [#974](https://github.com/penpot/penpot/issues/974) - Fix problem with locked shapes when change parents [#974](https://github.com/penpot/penpot/issues/974)
- Fix problem with new nodes in paths [#978](https://github.com/penpot/penpot/issues/978)
### :arrow_up: Deps updates ### :arrow_up: Deps updates

View file

@ -167,6 +167,7 @@
(loop [segments [] (loop [segments []
prev-point nil prev-point nil
start-point nil start-point nil
index 0
cur-cmd (first content) cur-cmd (first content)
content (rest content)] content (rest content)]
@ -191,12 +192,16 @@
segments (cond-> segments segments (cond-> segments
is-segment? is-segment?
(conj [prev-point cur-point cur-cmd]))] (conj {:start prev-point
:end cur-point
:cmd cur-cmd
:index index}))]
(if (some? cur-cmd) (if (some? cur-cmd)
(recur segments (recur segments
cur-point cur-point
start-point start-point
(inc index)
(first content) (first content)
(rest content)) (rest content))
@ -205,12 +210,13 @@
(defn split-segments (defn split-segments
"Given a content creates splits commands between points with new segments" "Given a content creates splits commands between points with new segments"
[content points value] [content points value]
(let [split-command (let [split-command
(fn [[start end cmd]] (fn [{:keys [start end cmd index]}]
(case (:command cmd) (case (:command cmd)
:line-to [cmd (upg/split-line-to start cmd value)] :line-to [index (upg/split-line-to start cmd value)]
:curve-to [cmd (upg/split-curve-to start cmd value)] :curve-to [index (upg/split-curve-to start cmd value)]
:close-path [cmd [(upc/make-line-to (gpt/line-val start end value)) cmd]] :close-path [index [(upc/make-line-to (gpt/line-val start end value)) cmd]]
nil)) nil))
cmd-changes cmd-changes
@ -219,12 +225,12 @@
(filter (comp not nil?))))) (filter (comp not nil?)))))
process-segments process-segments
(fn [command] (fn [[index command]]
(if (contains? cmd-changes command) (if (contains? cmd-changes index)
(get cmd-changes command) (get cmd-changes index)
[command]))] [command]))]
(into [] (mapcat process-segments) content))) (into [] (mapcat process-segments) (d/enumerate content))))
(defn remove-nodes (defn remove-nodes
"Removes from content the points given. Will try to reconstruct the paths "Removes from content the points given. Will try to reconstruct the paths