mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 04:19:08 -05:00
🐛 Fix problem calculating selrect for certain paths
This commit is contained in:
parent
02ab545cda
commit
f6b182a3b5
2 changed files with 35 additions and 32 deletions
|
@ -340,29 +340,31 @@
|
||||||
(grc/points->rect points))))
|
(grc/points->rect points))))
|
||||||
|
|
||||||
(defn content->selrect [content]
|
(defn content->selrect [content]
|
||||||
(let [calc-extremities
|
(let [extremities
|
||||||
(fn [command prev]
|
(loop [points #{}
|
||||||
(case (:command command)
|
from-p nil
|
||||||
:move-to [(command->point command)]
|
move-p nil
|
||||||
|
content (seq content)]
|
||||||
|
(if content
|
||||||
|
(let [command (first content)
|
||||||
|
to-p (command->point command)
|
||||||
|
|
||||||
;; If it's a line we add the beginning point and endpoint
|
[from-p move-p command-pts]
|
||||||
:line-to [(command->point prev)
|
(case (:command command)
|
||||||
(command->point command)]
|
:move-to [to-p to-p [to-p]]
|
||||||
|
:close-path [move-p move-p [move-p]]
|
||||||
|
:line-to [to-p move-p [from-p to-p]]
|
||||||
|
:curve-to [to-p move-p
|
||||||
|
(let [c1 (command->point command :c1)
|
||||||
|
c2 (command->point command :c2)
|
||||||
|
curve [from-p to-p c1 c2]]
|
||||||
|
(into [from-p to-p]
|
||||||
|
(->> (curve-extremities curve)
|
||||||
|
(map #(curve-values curve %)))))]
|
||||||
|
[to-p move-p []])]
|
||||||
|
|
||||||
;; We return the bezier extremities
|
(recur (apply conj points command-pts) from-p move-p (next content)))
|
||||||
:curve-to (into [(command->point prev)
|
points))]
|
||||||
(command->point command)]
|
|
||||||
(let [curve [(command->point prev)
|
|
||||||
(command->point command)
|
|
||||||
(command->point command :c1)
|
|
||||||
(command->point command :c2)]]
|
|
||||||
(->> (curve-extremities curve)
|
|
||||||
(map #(curve-values curve %)))))
|
|
||||||
[]))
|
|
||||||
|
|
||||||
extremities (mapcat calc-extremities
|
|
||||||
content
|
|
||||||
(concat [nil] content))]
|
|
||||||
(grc/points->rect extremities)))
|
(grc/points->rect extremities)))
|
||||||
|
|
||||||
(defn move-content [content move-vec]
|
(defn move-content [content move-vec]
|
||||||
|
|
|
@ -1013,20 +1013,21 @@
|
||||||
(d/ordered-set)))]
|
(d/ordered-set)))]
|
||||||
(rx/of (dws/select-shapes shapes-to-select)))
|
(rx/of (dws/select-shapes shapes-to-select)))
|
||||||
|
|
||||||
(let [{:keys [id type shapes]} (get objects (first selected))]
|
(when (d/not-empty? selected)
|
||||||
(case type
|
(let [{:keys [id type shapes]} (get objects (first selected))]
|
||||||
:text
|
(case type
|
||||||
(rx/of (dwe/start-edition-mode id))
|
:text
|
||||||
|
(rx/of (dwe/start-edition-mode id))
|
||||||
|
|
||||||
(:group :bool :frame)
|
(:group :bool :frame)
|
||||||
(let [shapes-ids (into (d/ordered-set) shapes)]
|
(let [shapes-ids (into (d/ordered-set) shapes)]
|
||||||
(rx/of (dws/select-shapes shapes-ids)))
|
(rx/of (dws/select-shapes shapes-ids)))
|
||||||
|
|
||||||
:svg-raw
|
:svg-raw
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(rx/of (dwe/start-edition-mode id)
|
(rx/of (dwe/start-edition-mode id)
|
||||||
(dwdp/start-path-edit id)))))))))
|
(dwdp/start-path-edit id))))))))))
|
||||||
|
|
||||||
(defn select-parent-layer
|
(defn select-parent-layer
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Add table
Reference in a new issue