Ability to add multiple strokes to a shape

This commit is contained in:
Alejandro Alonso
2022-02-17 15:19:36 +01:00
committed by Alonso Torres
parent 719aacd6f8
commit a73a393e26
30 changed files with 680 additions and 353 deletions

View File

@@ -9,7 +9,7 @@
[app.common.colors :as clr]
[app.common.uuid :as uuid]))
(def file-version 14)
(def file-version 15)
(def default-color clr/gray-20)
(def root uuid/zero)
@@ -32,6 +32,7 @@
:letter-spacing :text-display-group
:line-height :text-display-group
:text-align :text-display-group
:strokes :stroke-group
:stroke-color :stroke-group
:stroke-color-gradient :stroke-group
:stroke-color-ref-file :stroke-group
@@ -84,7 +85,19 @@
:fill-color-ref-id
:fill-color-ref-file
:fill-color-gradient
:hide-fill-on-export}
:hide-fill-on-export
:strokes
:stroke-style
:stroke-alignment
:stroke-width
:stroke-color
:stroke-color-ref-id
:stroke-color-ref-file
:stroke-opacity
:stroke-color-gradient
:stroke-cap-start
:stroke-cap-end}
:group #{:proportion-lock
:width :height
@@ -131,7 +144,8 @@
:fill-color-ref-id
:fill-color-ref-file
:fill-color-gradient
:strokes
:stroke-style
:stroke-alignment
:stroke-width
@@ -171,6 +185,7 @@
:fill-color-ref-file
:fill-color-gradient
:strokes
:stroke-style
:stroke-alignment
:stroke-width
@@ -210,6 +225,7 @@
:fill-color-ref-file
:fill-color-gradient
:strokes
:stroke-style
:stroke-alignment
:stroke-width
@@ -339,6 +355,7 @@
:fill-color-ref-file
:fill-color-gradient
:strokes
:stroke-style
:stroke-alignment
:stroke-width

View File

@@ -35,6 +35,7 @@
{:frame-id uuid/zero
:fills [{:fill-color clr/white
:fill-opacity 1}]
:strokes []
:shapes []
:hide-fill-on-export false})
@@ -43,47 +44,32 @@
:name "Rect-1"
:fills [{:fill-color default-color
:fill-opacity 1}]
:stroke-style :none
:stroke-alignment :center
:stroke-width 0
:stroke-color clr/black
:stroke-opacity 0
:strokes []
:rx 0
:ry 0}
{:type :image
:rx 0
:ry 0
:fills []}
:fills []
:strokes []}
{:type :circle
:name "Circle-1"
:fills [{:fill-color default-color
:fill-opacity 1}]
:stroke-style :none
:stroke-alignment :center
:stroke-width 0
:stroke-color clr/black
:stroke-opacity 0}
:strokes []}
{:type :path
:name "Path-1"
:fills []
:stroke-style :solid
:stroke-alignment :center
:stroke-width 2
:stroke-color clr/black
:stroke-opacity 1}
:strokes []}
{:type :frame
:name "Artboard-1"
:fills [{:fill-color clr/white
:fill-opacity 1}]
:stroke-style :none
:stroke-alignment :center
:stroke-width 0
:stroke-color clr/black
:stroke-opacity 0}
:strokes []}
{:type :text
:name "Text-1"

View File

@@ -310,13 +310,9 @@
:fill-opacity (:fill-opacity shape)}
clean-attrs (d/without-nils attrs)]
(-> shape
(assoc :fills [clean-attrs])
(dissoc :fill-color)
(dissoc :fill-color-gradient)
(dissoc :fill-color-ref-file)
(dissoc :fill-color-ref-id)
(dissoc :fill-opacity))))
(cond-> shape
(not (empty? clean-attrs))
(assoc :fills [clean-attrs]))))
;; Add fills to shapes
(defmethod migrate 14
@@ -328,5 +324,34 @@
(update-page [_ page]
(update page :objects #(d/mapm update-object %)))]
(update data :pages-index #(d/mapm update-page %))))
(defn set-strokes
[shape]
(let [attrs {:stroke-style (:stroke-style shape)
:stroke-alignment (:stroke-alignment shape)
:stroke-width (:stroke-width shape)
:stroke-color (:stroke-color shape)
:stroke-color-ref-id (:stroke-color-ref-id shape)
:stroke-color-ref-file (:stroke-color-ref-file shape)
:stroke-opacity (:stroke-opacity shape)
:stroke-color-gradient (:stroke-color-gradient shape)
:stroke-cap-start (:stroke-cap-start shape)
:stroke-cap-end (:stroke-cap-end shape)}
clean-attrs (d/without-nils attrs)]
(cond-> shape
(not (empty? clean-attrs))
(assoc :strokes [clean-attrs]))))
;; Add strokes to shapes
(defmethod migrate 15
[data]
(letfn [(update-object [_ object]
(cond-> object
(and (not (= :text (:type object))) (nil? (:strokes object)))
(set-strokes)))
(update-page [_ page]
(update page :objects #(d/mapm update-object %)))]
(update data :pages-index #(d/mapm update-page %))))