mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 18:18:24 +02:00
✨ Improved geometry for rects
This commit is contained in:
parent
23d531a664
commit
94c5004c33
7 changed files with 228 additions and 88 deletions
|
@ -23,8 +23,6 @@
|
|||
(toString [_]
|
||||
(str "matrix(" a "," b "," c "," d "," e "," f ")")))
|
||||
|
||||
(defonce matrix-regex #"matrix\((.*),(.*),(.*),(.*),(.*),(.*)\)")
|
||||
|
||||
(defn matrix
|
||||
"Create a new matrix instance."
|
||||
([]
|
||||
|
@ -32,13 +30,6 @@
|
|||
([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}]
|
||||
|
@ -64,8 +55,6 @@
|
|||
[v]
|
||||
(instance? Matrix v))
|
||||
|
||||
|
||||
|
||||
(def base (matrix))
|
||||
|
||||
(defn base?
|
||||
|
|
|
@ -204,6 +204,11 @@
|
|||
(defn to-vec [p1 p2]
|
||||
(subtract p2 p1))
|
||||
|
||||
(defn scale [v scalar]
|
||||
(-> v
|
||||
(update :x * scalar)
|
||||
(update :y * scalar)))
|
||||
|
||||
(defn dot [{x1 :x y1 :y} {x2 :x y2 :y}]
|
||||
(+ (* x1 x2) (* y1 y2)))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue