From 959c9986642e8256ecede56f77d39dc9c45227a4 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 5 Nov 2021 15:42:49 +0100 Subject: [PATCH] :bug: Fix a worker error when transforming a rectangle into path --- CHANGES.md | 1 + .../src/app/common/geom/shapes/intersect.cljc | 30 ++++++++++--------- .../src/app/common/path/shapes_to_path.cljc | 7 +---- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 085a1609e..136aff9b0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ - 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) - 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 ### :heart: Community contributions by (Thank you!) diff --git a/common/src/app/common/geom/shapes/intersect.cljc b/common/src/app/common/geom/shapes/intersect.cljc index 3cc358965..14360639f 100644 --- a/common/src/app/common/geom/shapes/intersect.cljc +++ b/common/src/app/common/geom/shapes/intersect.cljc @@ -6,6 +6,7 @@ (ns app.common.geom.shapes.intersect (:require + [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes.path :as gpp] @@ -172,22 +173,23 @@ "Checks if the given rect overlaps with the path in any point" [shape rect] - (let [;; If paths are too complex the intersection is too expensive - ;; we fallback to check its bounding box otherwise the performance penalty - ;; is too big - ;; TODO: Look for ways to optimize this operation - simple? (> (count (:content shape)) 100) + (when (d/not-empty? (:content shape)) + (let [ ;; If paths are too complex the intersection is too expensive + ;; we fallback to check its bounding box otherwise the performance penalty + ;; is too big + ;; TODO: Look for ways to optimize this operation + simple? (> (count (:content shape)) 100) - rect-points (gpr/rect->points rect) - rect-lines (points->lines rect-points) - path-lines (if simple? - (points->lines (:points shape)) - (gpp/path->lines shape)) - start-point (-> shape :content (first) :params (gpt/point))] + rect-points (gpr/rect->points rect) + rect-lines (points->lines rect-points) + path-lines (if simple? + (points->lines (:points shape)) + (gpp/path->lines shape)) + start-point (-> shape :content (first) :params (gpt/point))] - (or (is-point-inside-nonzero? (first rect-points) path-lines) - (is-point-inside-nonzero? start-point rect-lines) - (intersects-lines? rect-lines path-lines)))) + (or (is-point-inside-nonzero? (first rect-points) path-lines) + (is-point-inside-nonzero? start-point rect-lines) + (intersects-lines? rect-lines path-lines))))) (defn is-point-inside-ellipse? "checks if a point is inside an ellipse" diff --git a/common/src/app/common/path/shapes_to_path.cljc b/common/src/app/common/path/shapes_to_path.cljc index b95437d52..3a60ebbd5 100644 --- a/common/src/app/common/path/shapes_to_path.cljc +++ b/common/src/app/common/path/shapes_to_path.cljc @@ -177,12 +177,7 @@ (map #(get objects %)) (map #(convert-to-path % objects))) bool-type (:bool-type shape) - head (if (= bool-type :difference) (first children) (last 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))] + content (pb/content-bool bool-type (mapv :content children))] (-> shape (assoc :type :path)