From 3d66ae21de42ba149f7b26952930c7618e272752 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 7 Feb 2024 11:09:54 +0100 Subject: [PATCH] :bug: Fix problem with line caps --- frontend/src/app/main/ui/shapes/attrs.cljs | 12 +++++++----- frontend/src/app/main/ui/shapes/custom_stroke.cljs | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index 200801136..43fb21123 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -90,7 +90,7 @@ attrs)) (defn add-stroke! - [attrs data render-id index] + [attrs data render-id index open-path?] (let [style (:stroke-style data :solid)] (when-not (= style :none) (let [width (:stroke-width data 1) @@ -122,16 +122,18 @@ (cond (and (contains? stroke-caps-line caps-start) (= caps-start caps-end) - (not= :inner alignment) - (not= :outer alignment) + (or open-path? + (and (not= :inner alignment) + (not= :outer alignment))) (not= :dotted style)) (obj/set! attrs "strokeLinecap" (name caps-start)) (= :dotted style) (obj/set! attrs "strokeLinecap" "round")) - (when (and (not= :inner alignment) - (not= :outer alignment)) + (when (or open-path? + (and (not= :inner alignment) + (not= :outer alignment))) ;; For other cap types we use markers. (when (or (contains? stroke-caps-marker caps-start) diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index 32dfaf9b9..6366c42e0 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -420,7 +420,7 @@ (mf/html [:> type props]))) (defn- build-stroke-element - [child value position render-id] + [child value position render-id open-path?] (let [props (obj/get child "props") type (obj/get child "type") @@ -428,7 +428,7 @@ (obj/clone) (obj/set! "fill" "none") (obj/set! "fillOpacity" "none") - (attrs/add-stroke! value render-id position)) + (attrs/add-stroke! value render-id position open-path?)) style (if (:stroke-image value) (obj/set! style "stroke" (dm/fmt "url(#stroke-fill-%-%)" render-id position)) @@ -484,9 +484,10 @@ props (mf/spread-props svg-attrs {:id stroke-id :className "strokes" - :style style})] - + :style style}) + open-path? (and ^boolean (cfh/path-shape? shape) + ^boolean (gsh/open-path? shape))] (when-not ^boolean (cfh/frame-shape? shape) (when (and (some? shape-blur) (not ^boolean (:hidden shape-blur))) @@ -503,7 +504,7 @@ :stroke value :index index :key (dm/str index "-" stroke-id)} - (build-stroke-element child value index render-id)])]))) + (build-stroke-element child value index render-id open-path?)])]))) (mf/defc shape-custom-strokes {::mf/wrap-props false}