mirror of
https://github.com/penpot/penpot.git
synced 2025-06-24 06:16:59 +02:00
🐛 Fix a worker error when transforming a rectangle into path
This commit is contained in:
parent
b6b6b6043c
commit
959c998664
3 changed files with 18 additions and 20 deletions
|
@ -21,6 +21,7 @@
|
||||||
- Fix problem with text rendering on export [Taiga #2223](https://tree.taiga.io/project/penpot/issue/2223)
|
- Fix problem with text rendering on export [Taiga #2223](https://tree.taiga.io/project/penpot/issue/2223)
|
||||||
- Fix problem when flattening booleans losing styles [Taiga #2217](https://tree.taiga.io/project/penpot/issue/2217)
|
- Fix problem when flattening booleans losing styles [Taiga #2217](https://tree.taiga.io/project/penpot/issue/2217)
|
||||||
- Add shortcuts to boolean icons popups [Taiga #2220](https://tree.taiga.io/project/penpot/issue/2220)
|
- Add shortcuts to boolean icons popups [Taiga #2220](https://tree.taiga.io/project/penpot/issue/2220)
|
||||||
|
- Fix a worker error when transforming a rectangle into path
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.common.geom.shapes.intersect
|
(ns app.common.geom.shapes.intersect
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes.path :as gpp]
|
[app.common.geom.shapes.path :as gpp]
|
||||||
|
@ -172,22 +173,23 @@
|
||||||
"Checks if the given rect overlaps with the path in any point"
|
"Checks if the given rect overlaps with the path in any point"
|
||||||
[shape rect]
|
[shape rect]
|
||||||
|
|
||||||
(let [;; If paths are too complex the intersection is too expensive
|
(when (d/not-empty? (:content shape))
|
||||||
;; we fallback to check its bounding box otherwise the performance penalty
|
(let [ ;; If paths are too complex the intersection is too expensive
|
||||||
;; is too big
|
;; we fallback to check its bounding box otherwise the performance penalty
|
||||||
;; TODO: Look for ways to optimize this operation
|
;; is too big
|
||||||
simple? (> (count (:content shape)) 100)
|
;; TODO: Look for ways to optimize this operation
|
||||||
|
simple? (> (count (:content shape)) 100)
|
||||||
|
|
||||||
rect-points (gpr/rect->points rect)
|
rect-points (gpr/rect->points rect)
|
||||||
rect-lines (points->lines rect-points)
|
rect-lines (points->lines rect-points)
|
||||||
path-lines (if simple?
|
path-lines (if simple?
|
||||||
(points->lines (:points shape))
|
(points->lines (:points shape))
|
||||||
(gpp/path->lines shape))
|
(gpp/path->lines shape))
|
||||||
start-point (-> shape :content (first) :params (gpt/point))]
|
start-point (-> shape :content (first) :params (gpt/point))]
|
||||||
|
|
||||||
(or (is-point-inside-nonzero? (first rect-points) path-lines)
|
(or (is-point-inside-nonzero? (first rect-points) path-lines)
|
||||||
(is-point-inside-nonzero? start-point rect-lines)
|
(is-point-inside-nonzero? start-point rect-lines)
|
||||||
(intersects-lines? rect-lines path-lines))))
|
(intersects-lines? rect-lines path-lines)))))
|
||||||
|
|
||||||
(defn is-point-inside-ellipse?
|
(defn is-point-inside-ellipse?
|
||||||
"checks if a point is inside an ellipse"
|
"checks if a point is inside an ellipse"
|
||||||
|
|
|
@ -177,12 +177,7 @@
|
||||||
(map #(get objects %))
|
(map #(get objects %))
|
||||||
(map #(convert-to-path % objects)))
|
(map #(convert-to-path % objects)))
|
||||||
bool-type (:bool-type shape)
|
bool-type (:bool-type shape)
|
||||||
head (if (= bool-type :difference) (first children) (last children))
|
content (pb/content-bool bool-type (mapv :content children))]
|
||||||
head (cond-> head
|
|
||||||
(and (contains? head :svg-attrs) (nil? (:fill-color head)))
|
|
||||||
(assoc :fill-color "#000000"))
|
|
||||||
|
|
||||||
content (pb/content-bool (:bool-type shape) (mapv :content children))]
|
|
||||||
|
|
||||||
(-> shape
|
(-> shape
|
||||||
(assoc :type :path)
|
(assoc :type :path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue