diff --git a/common/src/app/common/geom/shapes/effects.cljc b/common/src/app/common/geom/shapes/effects.cljc index 912b2de6c..8cac7e25b 100644 --- a/common/src/app/common/geom/shapes/effects.cljc +++ b/common/src/app/common/geom/shapes/effects.cljc @@ -1,3 +1,9 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + (ns app.common.geom.shapes.effects) (defn update-shadow-scale diff --git a/common/src/app/common/geom/shapes/path.cljc b/common/src/app/common/geom/shapes/path.cljc index 941b3ffc2..9295c421d 100644 --- a/common/src/app/common/geom/shapes/path.cljc +++ b/common/src/app/common/geom/shapes/path.cljc @@ -845,13 +845,11 @@ (defn close-content [content] (into [] - (comp (filter sp/is-closed?) - (mapcat :data)) + (mapcat :data) (->> content (sp/close-subpaths) (sp/get-subpaths)))) - (defn ray-overlaps? [ray-point {selrect :selrect}] (and (>= (:y ray-point) (:y1 selrect)) diff --git a/common/src/app/common/geom/shapes/strokes.cljc b/common/src/app/common/geom/shapes/strokes.cljc index 272e5e12b..905aac030 100644 --- a/common/src/app/common/geom/shapes/strokes.cljc +++ b/common/src/app/common/geom/shapes/strokes.cljc @@ -1,3 +1,9 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + (ns app.common.geom.shapes.strokes) (defn update-stroke-width diff --git a/common/src/app/common/types/modifiers.cljc b/common/src/app/common/types/modifiers.cljc index 7967d0379..d0669a024 100644 --- a/common/src/app/common/types/modifiers.cljc +++ b/common/src/app/common/types/modifiers.cljc @@ -737,30 +737,32 @@ (apply-scale-content [shape value] - (cond-> shape - (cfh/text-shape? shape) - (update-text-content scale-text-content value) + ;; Scale can only be positive + (let [value (mth/abs value)] + (cond-> shape + (cfh/text-shape? shape) + (update-text-content scale-text-content value) - :always - (gsc/update-corners-scale value) + :always + (gsc/update-corners-scale value) - (d/not-empty? (:strokes shape)) - (gss/update-strokes-width value) + (d/not-empty? (:strokes shape)) + (gss/update-strokes-width value) - (d/not-empty? (:shadow shape)) - (gse/update-shadows-scale value) + (d/not-empty? (:shadow shape)) + (gse/update-shadows-scale value) - (some? (:blur shape)) - (gse/update-blur-scale value) + (some? (:blur shape)) + (gse/update-blur-scale value) - (ctl/flex-layout? shape) - (ctl/update-flex-scale value) + (ctl/flex-layout? shape) + (ctl/update-flex-scale value) - (ctl/grid-layout? shape) - (ctl/update-grid-scale value) + (ctl/grid-layout? shape) + (ctl/update-grid-scale value) - :always - (ctl/update-flex-child value)))] + :always + (ctl/update-flex-child value))))] (let [remove-children (fn [shapes children-to-remove] diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 80e38ab3e..a69805cdc 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -971,7 +971,7 @@ selrect (gsh/shapes->rect shapes) center (grc/rect->center selrect) modifiers (dwm/create-modif-tree selected (ctm/resize-modifiers (gpt/point -1.0 1.0) center))] - (rx/of (dwm/apply-modifiers {:modifiers modifiers})))))) + (rx/of (dwm/apply-modifiers {:modifiers modifiers :ignore-snap-pixel true})))))) (defn flip-vertical-selected [] (ptk/reify ::flip-vertical-selected @@ -983,4 +983,4 @@ selrect (gsh/shapes->rect shapes) center (grc/rect->center selrect) modifiers (dwm/create-modif-tree selected (ctm/resize-modifiers (gpt/point 1.0 -1.0) center))] - (rx/of (dwm/apply-modifiers {:modifiers modifiers})))))) + (rx/of (dwm/apply-modifiers {:modifiers modifiers :ignore-snap-pixel true})))))) diff --git a/frontend/src/app/main/ui/workspace/shapes/debug.cljs b/frontend/src/app/main/ui/workspace/shapes/debug.cljs index e1353644b..8844d18bc 100644 --- a/frontend/src/app/main/ui/workspace/shapes/debug.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/debug.cljs @@ -10,8 +10,12 @@ [app.common.data.macros :as dm] [app.common.files.helpers :as cfh] [app.common.geom.shapes :as gsh] + [app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.text :as gst] [app.common.math :as mth] + [app.common.svg.path.bool :as pb] + [app.common.svg.path.shapes-to-path :as stp] + [app.common.svg.path.subpath :as ups] [app.main.refs :as refs] [app.util.color :as uc] [app.util.debug :as dbg] @@ -87,13 +91,98 @@ :style {:stroke "green" :stroke-width (/ 2 zoom)}}]]))])) +(mf/defc debug-bool-shape + {::mf/wrap-props false} + [{:keys [shape]}] + + (let [objects (mf/deref refs/workspace-page-objects) + zoom (mf/deref refs/selected-zoom) + + radius (/ 3 zoom) + + c1 (-> (get objects (first (:shapes shape))) + (stp/convert-to-path objects)) + c2 (-> (get objects (second (:shapes shape))) + (stp/convert-to-path objects)) + + content-a (:content c1) + content-b (:content c2) + + bool-type (:bool-type shape) + should-reverse? (and (not= :union bool-type) + (= (ups/clockwise? content-b) + (ups/clockwise? content-a))) + + content-a (-> (:content c1) + (pb/close-paths) + (pb/add-previous)) + + content-b (-> (:content c2) + (pb/close-paths) + (cond-> should-reverse? (ups/reverse-content)) + (pb/add-previous)) + + + sr-a (gsp/content->selrect content-a) + sr-b (gsp/content->selrect content-b) + + [content-a-split content-b-split] (pb/content-intersect-split content-a content-b sr-a sr-b) + + ;;content-a-geom (gsp/content->geom-data content-a) + ;;content-b-geom (gsp/content->geom-data content-b) + ;;content-a-split (->> content-a-split #_(filter #(pb/contains-segment? % content-b sr-b content-b-geom))) + ;;content-b-split (->> content-b-split #_(filter #(pb/contains-segment? % content-a sr-a content-a-geom))) + ] + [:* + (for [[i cmd] (d/enumerate content-a-split)] + (let [p1 (:prev cmd) + p2 (gsp/command->point cmd) + + hp (case (:command cmd) + :line-to (-> (gsp/command->line cmd) + (gsp/line-values 0.5)) + + :curve-to (-> (gsp/command->bezier cmd) + (gsp/curve-values 0.5)) + nil)] + [:* + (when p1 + [:circle {:data-i i :key (dm/str "c11-" i) :cx (:x p1) :cy (:y p1) :r radius :fill "red"}]) + [:circle {:data-i i :key (dm/str "c12-" i) :cx (:x p2) :cy (:y p2) :r radius :fill "red"}] + + (when hp + [:circle {:data-i i :key (dm/str "c13-" i) :cx (:x hp) :cy (:y hp) :r radius :fill "orange"}])])) + + (for [[i cmd] (d/enumerate content-b-split)] + (let [p1 (:prev cmd) + p2 (gsp/command->point cmd) + + hp (case (:command cmd) + :line-to (-> (gsp/command->line cmd) + (gsp/line-values 0.5)) + + :curve-to (-> (gsp/command->bezier cmd) + (gsp/curve-values 0.5)) + nil)] + [:* + (when p1 + [:circle {:key (dm/str "c21-" i) :cx (:x p1) :cy (:y p1) :r radius :fill "blue"}]) + [:circle {:key (dm/str "c22-" i) :cx (:x p2) :cy (:y p2) :r radius :fill "blue"}] + + (when hp + [:circle {:data-i i :key (dm/str "c13-" i) :cx (:x hp) :cy (:y hp) :r radius :fill "green"}])]))])) + (mf/defc shape-debug [{:keys [shape]}] [:* (when ^boolean (dbg/enabled? :bounding-boxes) [:& debug-bounding-boxes {:shape shape}]) - (when (and ^boolean (cfh/text-shape? shape) - ^boolean (dbg/enabled? :text-outline) + (when (and ^boolean (dbg/enabled? :bool-shapes) + ^boolean (cfh/bool-shape? shape)) + [:& debug-bool-shape {:shape shape}]) + + (when (and ^boolean (dbg/enabled? :text-outline) + ^boolean (cfh/text-shape? shape) ^boolean (seq (:position-data shape))) [:& debug-text-bounds {:shape shape}])]) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 2a808e627..8539def89 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -553,7 +553,7 @@ :offset-y offset-y :show-rulers? show-rulers?}]) - (when show-rulers? + (when (and show-rulers? show-grids?) [:& guides/viewport-guides {:zoom zoom :vbox vbox diff --git a/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs b/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs index 69597f5a1..0da613105 100644 --- a/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs @@ -27,7 +27,7 @@ (i/icon-xref :add (stl/css :add-icon :pathbar-icon))) (def ^:private remove-icon - (i/icon-xref :remove-icon (stl/css :remove-icon :pathbar-icon))) + (i/icon-xref :remove (stl/css :remove :pathbar-icon))) (def ^:private merge-nodes-icon (i/icon-xref :merge-nodes (stl/css :merge-nodes-icon :pathbar-icon))) diff --git a/frontend/src/app/main/ui/workspace/viewport/rulers.cljs b/frontend/src/app/main/ui/workspace/viewport/rulers.cljs index ff9624638..423701445 100644 --- a/frontend/src/app/main/ui/workspace/viewport/rulers.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/rulers.cljs @@ -101,13 +101,13 @@ rulers-size (* rulers-size zoom-inverse)] (if (= axis :x) {:text-x val - :text-y (+ (:y vbox) (- rulers-pos (* 4 zoom-inverse))) + :text-y (+ (:y vbox) rulers-pos (* -1 zoom-inverse)) :line-x1 val :line-y1 (+ (:y vbox) rulers-pos (* 2 zoom-inverse)) :line-x2 val :line-y2 (+ (:y vbox) rulers-pos (* 2 zoom-inverse) rulers-size)} - {:text-x (+ (:x vbox) (- rulers-pos (* 4 zoom-inverse))) + {:text-x (+ (:x vbox) rulers-pos (* -1 zoom-inverse)) :text-y val :line-x1 (+ (:x vbox) rulers-pos (* 2 zoom-inverse)) :line-y1 val @@ -171,7 +171,6 @@ [:text {:x text-x :y text-y :text-anchor "middle" - :dominant-baseline "middle" :transform (when (= axis :y) (str "rotate(-90 " text-x "," text-y ")")) :style {:font-size (* font-size zoom-inverse) :font-family font-family @@ -250,18 +249,16 @@ :fill-opacity selection-area-opacity}}] [:text {:x (- (:x1 selection-rect) (* 4 zoom-inverse)) - :y (+ (:y vbox) (* 10.6 zoom-inverse)) + :y (+ (:y vbox) (* 13.6 zoom-inverse)) :text-anchor "end" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} (fmt/format-number (- (:x1 selection-rect) offset-x))] [:text {:x (+ (:x2 selection-rect) (* 4 zoom-inverse)) - :y (+ (:y vbox) (* 10.6 zoom-inverse)) + :y (+ (:y vbox) (* 13.6 zoom-inverse)) :text-anchor "start" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} @@ -293,18 +290,16 @@ :fill-opacity over-number-opacity}}] [:text {:x (- center-x (/ (:height selection-rect) 2) (* 15 zoom-inverse)) - :y center-y + :y (+ center-y (* 4 zoom-inverse)) :text-anchor "end" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} (fmt/format-number (- (:y2 selection-rect) offset-y))] [:text {:x (+ center-x (/ (:height selection-rect) 2)) - :y center-y + :y (+ center-y (* 4 zoom-inverse)) :text-anchor "start" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} diff --git a/frontend/src/app/util/debug.cljs b/frontend/src/app/util/debug.cljs index 067ac8a54..094550cef 100644 --- a/frontend/src/app/util/debug.cljs +++ b/frontend/src/app/util/debug.cljs @@ -86,7 +86,10 @@ :shape-panel ;; Show what is touched in copies - :display-touched}) + :display-touched + + ;; Show some visual indicators for bool shape + :bool-shapes}) (defn enable! [option]