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

Add efficiency changes to get-segments helper

This commit is contained in:
Andrey Antukh 2024-08-26 15:45:32 +02:00
parent f302c724c4
commit ef3a47b492

View file

@ -184,18 +184,22 @@
cur-cmd (first content) cur-cmd (first content)
content (rest content)] content (rest content)]
(let [;; Close-path makes a segment from the last point to the initial path point (let [command (:command cur-cmd)
cur-point (if (= :close-path (:command cur-cmd)) close-path? (= command :close-path)
move-to? (= command :move-to)
;; Close-path makes a segment from the last point to the initial path point
cur-point (if close-path?
start-point start-point
(upc/command->point cur-cmd)) (upc/command->point cur-cmd))
;; If there is a move-to we don't have a segment ;; If there is a move-to we don't have a segment
prev-point (if (= :move-to (:command cur-cmd)) prev-point (if move-to?
nil nil
prev-point) prev-point)
;; We update the start point ;; We update the start point
start-point (if (= :move-to (:command cur-cmd)) start-point (if move-to?
cur-point cur-point
start-point) start-point)