mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
Improve point transformation helpers.
This commit is contained in:
parent
aed1b8cd26
commit
462f37e601
1 changed files with 10 additions and 4 deletions
|
@ -94,6 +94,12 @@
|
|||
(Point. (/ (:x p) (:x other))
|
||||
(/ (:y p) (:y other)))))
|
||||
|
||||
(defn negate
|
||||
[p]
|
||||
{:pre [(point? p)]}
|
||||
(let [{:keys [x y]} (-point p)]
|
||||
(Point. (- x) (- y))))
|
||||
|
||||
(defn distance
|
||||
"Calculate the distance between two points."
|
||||
[p other]
|
||||
|
@ -161,7 +167,7 @@
|
|||
|
||||
(defn transform
|
||||
"Transform a point applying a matrix transfomation."
|
||||
[{:keys [x y] :as p} {:keys [a b c d tx ty] :as m}]
|
||||
(Point. (+ (* x a) (* y c) tx)
|
||||
(+ (* x b) (* y d) ty)))
|
||||
|
||||
[pt {:keys [a b c d tx ty] :as m}]
|
||||
(let [{:keys [x y]} (point pt)]
|
||||
(Point. (+ (* x a) (* y c) tx)
|
||||
(+ (* x b) (* y d) ty))))
|
||||
|
|
Loading…
Add table
Reference in a new issue