mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 13:08:28 +02:00
🐛 Fix problem with mix between open/closed and line/curves
This commit is contained in:
parent
2833d3126f
commit
d2d506dbf0
1 changed files with 15 additions and 18 deletions
|
@ -126,8 +126,8 @@
|
||||||
|
|
||||||
(let [tangent (curve-tangent curve t)]
|
(let [tangent (curve-tangent curve t)]
|
||||||
(cond
|
(cond
|
||||||
(> (:y tangent) 0) 1
|
(> (:y tangent) 0) -1
|
||||||
(< (:y tangent) 0) -1
|
(< (:y tangent) 0) 1
|
||||||
:else 0)))
|
:else 0)))
|
||||||
|
|
||||||
(defn curve-split
|
(defn curve-split
|
||||||
|
@ -822,30 +822,27 @@
|
||||||
(let [selrect (content->selrect content)
|
(let [selrect (content->selrect content)
|
||||||
ray-line [point (gpt/point (inc (:x point)) (:y point))]
|
ray-line [point (gpt/point (inc (:x point)) (:y point))]
|
||||||
|
|
||||||
closed-subpaths
|
closed-content
|
||||||
(->> content
|
(into []
|
||||||
(sp/close-subpaths)
|
(comp (filter sp/is-closed?)
|
||||||
(sp/get-subpaths)
|
(mapcat :data))
|
||||||
(filterv sp/is-closed?))
|
(->> content
|
||||||
|
(sp/close-subpaths)
|
||||||
|
(sp/get-subpaths)))
|
||||||
|
|
||||||
cast-ray
|
cast-ray
|
||||||
(fn [cmd]
|
(fn [cmd]
|
||||||
(case (:command cmd)
|
(case (:command cmd)
|
||||||
:line-to (ray-line-intersect point (command->line cmd))
|
:line-to (ray-line-intersect point (command->line cmd))
|
||||||
:curve-to (ray-curve-intersect ray-line (command->bezier cmd))
|
:curve-to (ray-curve-intersect ray-line (command->bezier cmd))
|
||||||
#_:else []))
|
#_:else []))]
|
||||||
|
|
||||||
is-point-in-subpath?
|
|
||||||
(fn [subpath]
|
|
||||||
(and (gpr/contains-point? (content->selrect (:data subpath)) point)
|
|
||||||
(->> (:data subpath)
|
|
||||||
(mapcat cast-ray)
|
|
||||||
(map second)
|
|
||||||
(reduce +)
|
|
||||||
(not= 0))))]
|
|
||||||
|
|
||||||
(and (gpr/contains-point? selrect point)
|
(and (gpr/contains-point? selrect point)
|
||||||
(some is-point-in-subpath? closed-subpaths))))
|
(->> closed-content
|
||||||
|
(mapcat cast-ray)
|
||||||
|
(map second)
|
||||||
|
(reduce +)
|
||||||
|
(not= 0)))))
|
||||||
|
|
||||||
(defn split-line-to
|
(defn split-line-to
|
||||||
"Given a point and a line-to command will create a two new line-to commands
|
"Given a point and a line-to command will create a two new line-to commands
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue