0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-17 10:11:22 -05:00

Merge pull request #1292 from penpot/bugfix

Bug fixing
This commit is contained in:
Andrey Antukh 2021-10-20 15:05:50 +02:00 committed by GitHub
commit 5ec73da17f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 63 additions and 22 deletions

View file

@ -41,6 +41,12 @@
- Fix path stroke is not working properly with high thickness [Taiga #2154](https://tree.taiga.io/project/penpot/issue/2154).
- Fix bug with transformation operations [Taiga #2155](https://tree.taiga.io/project/penpot/issue/2155).
- Fix bug in firefox when a text box is inside a mask [Taiga #2152](https://tree.taiga.io/project/penpot/issue/2152).
- Fix problem with stroke inside/outside [Taiga #2186](https://tree.taiga.io/project/penpot/issue/2186)
- Fix masks export area [Taiga #2189](https://tree.taiga.io/project/penpot/issue/2189)
- Fix paste in place in arboards [Taiga #2188](https://tree.taiga.io/project/penpot/issue/2188)
- Fix font size input stuck on selection change [Taiga #2184](https://tree.taiga.io/project/penpot/issue/2184)
- Fix stroke cut on shapes export [Taiga #2171](https://tree.taiga.io/project/penpot/issue/2171)
- Fix no color when boolean with an SVG [Taiga #2193](https://tree.taiga.io/project/penpot/issue/2193)
### :arrow_up: Deps updates

View file

@ -13,7 +13,8 @@
[app.common.geom.shapes.intersect :as gin]
[app.common.geom.shapes.path :as gsp]
[app.common.geom.shapes.rect :as gpr]
[app.common.geom.shapes.transforms :as gtr]))
[app.common.geom.shapes.transforms :as gtr]
[app.common.math :as mth]))
;; --- Setup (Initialize)
;; FIXME: Is this the correct place for these functions?
@ -127,6 +128,13 @@
(assoc :selrect selrect
:points points))))
(defn shape-stroke-margin
[shape stroke-width]
(if (= (:type shape) :path)
;; TODO: Calculate with the stroke offset (not implemented yet
(mth/sqrt (* 2 stroke-width stroke-width))
(- (mth/sqrt (* 2 stroke-width stroke-width)) stroke-width)))
;; EXPORTS
(d/export gco/center-shape)

View file

@ -176,7 +176,12 @@
(let [children (->> (:shapes shape)
(map #(get objects %))
(map #(convert-to-path % objects)))
head (first children)
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"))
head-data (select-keys head style-properties)
content (pb/content-bool (:bool-type shape) (mapv :content children))]

View file

@ -1648,7 +1648,6 @@
;; Procceed with the standard shape paste procediment.
(do-paste [it state mouse-pos media]
(let [page-objects (wsh/lookup-page-objects state)
all-objects (merge page-objects paste-objects)
media-idx (d/index-by :prev-id media)
;; Calculate position for the pasted elements
@ -1670,6 +1669,8 @@
:shape-ref
:touched))))))
all-objects (merge page-objects paste-objects)
page-id (:current-page-id state)
unames (-> (wsh/lookup-page-objects state page-id)
(dwc/retrieve-used-names)) ;; TODO: move this calculation inside prepare-duplcate-changes?

View file

@ -33,6 +33,10 @@
[bool-type name shapes objects]
(let [shapes (mapv #(stp/convert-to-path % objects) shapes)
head (if (= bool-type :difference) (first shapes) (last shapes))
head (cond-> head
(and (contains? head :svg-attrs) (nil? (:fill-color head)))
(assoc :fill-color "#000000"))
head-data (select-keys head stp/style-properties)]
[(-> {:id (uuid/next)
:type :bool
@ -51,7 +55,10 @@
(let [shapes (->> (:shapes group)
(map #(get objects %))
(mapv #(stp/convert-to-path % objects)))
head (first shapes)
head (if (= bool-type :difference) (first shapes) (last shapes))
head (cond-> head
(and (contains? head :svg-attrs) (nil? (:fill-color head)))
(assoc :fill-color "#000000"))
head-data (select-keys head stp/style-properties)]
(-> group

View file

@ -76,6 +76,7 @@
handle-key-down
(mf/use-callback
(mf/deps set-value)
(fn [event]
(when (= type "number")
(let [up? (kbd/up-arrow? event)

View file

@ -37,11 +37,17 @@
(update :width + (* 2 padding))
(update :height + (* 2 padding)))]
(if (= :group (:type object))
(cond
(and (= :group (:type object))
(:masked-group? object))
(calc-bounds (get objects (first (:shapes object))) objects)
(= :group (:type object))
(->> (:shapes object)
(into [obj-bounds] xf-get-bounds)
(gsh/join-rects))
:else
obj-bounds)))
(mf/defc object-svg

View file

@ -35,8 +35,22 @@
[{:keys [shape render-id]}]
(let [stroke-mask-id (str "outer-stroke-" render-id)
shape-id (str "stroke-shape-" render-id)
stroke-width (:stroke-width shape 0)]
[:mask {:id stroke-mask-id}
stroke-width (case (:stroke-alignment shape :center)
:center (/ (:stroke-width shape 0) 2)
:outer (:stroke-width shape 0)
0)
margin (gsh/shape-stroke-margin shape stroke-width)
bounding-box (-> (gsh/points->selrect (:points shape))
(update :x - (+ stroke-width margin))
(update :y - (+ stroke-width margin))
(update :width + (* 2 (+ stroke-width margin)))
(update :height + (* 2 (+ stroke-width margin))))]
[:mask {:id stroke-mask-id
:x (:x bounding-box)
:y (:y bounding-box)
:width (:width bounding-box)
:height (:height bounding-box)
:maskUnits "userSpaceOnUse"}
[:use {:xlinkHref (str "#" shape-id)
:style #js {:fill "none" :stroke "white" :strokeWidth (* stroke-width 2)}}]
@ -146,8 +160,8 @@
(mf/defc stroke-defs
[{:keys [shape render-id]}]
(when (and (= (:type shape) :path)
(gsh/open-path? shape))
(when (or (not= (:type shape) :path)
(not (gsh/open-path? shape)))
(cond
(and (= :inner (:stroke-alignment shape :center))
(> (:stroke-width shape 0) 0))

View file

@ -202,17 +202,12 @@
:height (- y2 y1)})))))
(defn calculate-padding [shape]
(let [{:keys [stroke-style stroke-alignment stroke-width]} shape]
(cond
(and (not= stroke-style :none)
(= stroke-alignment :outer))
stroke-width
(and (not= stroke-style :none)
(= stroke-alignment :center))
(mth/ceil (/ stroke-width 2))
:else 0)))
(let [stroke-width (case (:stroke-alignment shape :center)
:center (/ (:stroke-width shape 0) 2)
:outer (:stroke-width shape 0)
0)
margin (gsh/shape-stroke-margin shape stroke-width)]
(+ stroke-width margin)))
(mf/defc filters
[{:keys [filter-id shape]}]
@ -221,9 +216,7 @@
;; Adds the previous filter as `filter-in` parameter
filters (map #(assoc %1 :filter-in %2) filters (cons nil (map :id filters)))
bounds (get-filters-bounds shape filters (or (-> shape :blur :value) 0))
padding (calculate-padding shape)]
[:*