mirror of
https://github.com/penpot/penpot.git
synced 2025-07-26 02:17:13 +02:00
✨ Improvements to loop removing
This commit is contained in:
parent
2184286a78
commit
1a7b098282
8 changed files with 96 additions and 73 deletions
|
@ -65,22 +65,20 @@
|
|||
|
||||
|
||||
(defn format-path [content]
|
||||
(let [content (ups/close-subpaths content)]
|
||||
(loop [result ""
|
||||
last-move nil
|
||||
(with-out-str
|
||||
(loop [last-move nil
|
||||
current (first content)
|
||||
content (rest content)]
|
||||
|
||||
(if (some? current)
|
||||
(when (some? current)
|
||||
(let [point (upc/command->point current)
|
||||
current-move? (= :move-to (:command current))
|
||||
result (str result (command->string current))
|
||||
result (if (and (not current-move?) (= last-move point))
|
||||
(str result "Z")
|
||||
result)
|
||||
last-move (if current-move? point last-move)]
|
||||
(recur result
|
||||
last-move
|
||||
(print (command->string current))
|
||||
|
||||
(when (and (not current-move?) (= last-move point))
|
||||
(print "Z"))
|
||||
|
||||
(recur last-move
|
||||
(first content)
|
||||
(rest content)))
|
||||
result))))
|
||||
(rest content)))))))
|
||||
|
|
|
@ -103,9 +103,7 @@
|
|||
(defn close-subpaths
|
||||
"Searches a path for posible supaths that can create closed loops and merge them"
|
||||
[content]
|
||||
|
||||
(let [subpaths (get-subpaths content)
|
||||
|
||||
closed-subpaths
|
||||
(loop [result []
|
||||
current (first subpaths)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue