mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 04:11:39 +02:00
✨ Import paths as native shapes
This commit is contained in:
parent
741d67c30b
commit
19febde547
28 changed files with 921 additions and 209 deletions
|
@ -302,6 +302,14 @@
|
|||
default
|
||||
v))))
|
||||
|
||||
(defn num-string? [v]
|
||||
;; https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
|
||||
#?(:cljs (and (string? v)
|
||||
(not (js/isNaN v))
|
||||
(not (js/isNaN (parse-double v))))
|
||||
|
||||
:clj (not= (parse-double v :nan) :nan)))
|
||||
|
||||
(defn read-string
|
||||
[v]
|
||||
(r/read-string v))
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
(:require
|
||||
#?(:cljs [cljs.pprint :as pp]
|
||||
:clj [clojure.pprint :as pp])
|
||||
[cuerdas.core :as str]
|
||||
[app.common.data :as d]
|
||||
[app.common.math :as mth]
|
||||
[app.common.geom.point :as gpt]))
|
||||
|
||||
|
@ -21,6 +23,22 @@
|
|||
(toString [_]
|
||||
(str "matrix(" a "," b "," c "," d "," e "," f ")")))
|
||||
|
||||
(defonce matrix-regex #"matrix\((.*),(.*),(.*),(.*),(.*),(.*)\)")
|
||||
|
||||
(defn matrix
|
||||
"Create a new matrix instance."
|
||||
([]
|
||||
(Matrix. 1 0 0 1 0 0))
|
||||
([a b c d e f]
|
||||
(Matrix. a b c d e f)))
|
||||
|
||||
(defn parse-matrix [mtx]
|
||||
(let [[_ a b c d e f] (re-matches matrix-regex mtx)]
|
||||
(->> [a b c d e f]
|
||||
(map str/trim)
|
||||
(map d/parse-double)
|
||||
(apply matrix))))
|
||||
|
||||
(defn multiply
|
||||
([{m1a :a m1b :b m1c :c m1d :d m1e :e m1f :f}
|
||||
{m2a :a m2b :b m2c :c m2d :d m2e :e m2f :f}]
|
||||
|
@ -46,12 +64,7 @@
|
|||
[v]
|
||||
(instance? Matrix v))
|
||||
|
||||
(defn matrix
|
||||
"Create a new matrix instance."
|
||||
([]
|
||||
(Matrix. 1 0 0 1 0 0))
|
||||
([a b c d e f]
|
||||
(Matrix. a b c d e f)))
|
||||
|
||||
|
||||
(def base (matrix))
|
||||
|
||||
|
|
|
@ -148,10 +148,10 @@
|
|||
(update-in [:selrect :x2] - x)
|
||||
(update-in [:selrect :y2] - y)
|
||||
|
||||
(d/update-when :points #(map move-point %))
|
||||
(d/update-when :points #(mapv move-point %))
|
||||
|
||||
(cond-> (= :path type)
|
||||
(d/update-when :content #(map move-segment %))))))
|
||||
(d/update-when :content #(mapv move-segment %))))))
|
||||
|
||||
|
||||
;; --- Helpers
|
||||
|
|
|
@ -229,7 +229,7 @@
|
|||
(s/def :internal.shape/stroke-color-ref-file (s/nilable uuid?))
|
||||
(s/def :internal.shape/stroke-color-ref-id (s/nilable uuid?))
|
||||
(s/def :internal.shape/stroke-opacity ::safe-number)
|
||||
(s/def :internal.shape/stroke-style #{:solid :dotted :dashed :mixed :none})
|
||||
(s/def :internal.shape/stroke-style #{:solid :dotted :dashed :mixed :none :svg})
|
||||
(s/def :internal.shape/stroke-width ::safe-number)
|
||||
(s/def :internal.shape/stroke-alignment #{:center :inner :outer})
|
||||
(s/def :internal.shape/text-align #{"left" "right" "center" "justify"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue