mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 06:28:47 +00:00
Improve point transformation helpers.
This commit is contained in:
parent
aed1b8cd26
commit
462f37e601
@ -94,6 +94,12 @@
|
|||||||
(Point. (/ (:x p) (:x other))
|
(Point. (/ (:x p) (:x other))
|
||||||
(/ (:y p) (:y other)))))
|
(/ (:y p) (:y other)))))
|
||||||
|
|
||||||
|
(defn negate
|
||||||
|
[p]
|
||||||
|
{:pre [(point? p)]}
|
||||||
|
(let [{:keys [x y]} (-point p)]
|
||||||
|
(Point. (- x) (- y))))
|
||||||
|
|
||||||
(defn distance
|
(defn distance
|
||||||
"Calculate the distance between two points."
|
"Calculate the distance between two points."
|
||||||
[p other]
|
[p other]
|
||||||
@ -161,7 +167,7 @@
|
|||||||
|
|
||||||
(defn transform
|
(defn transform
|
||||||
"Transform a point applying a matrix transfomation."
|
"Transform a point applying a matrix transfomation."
|
||||||
[{:keys [x y] :as p} {:keys [a b c d tx ty] :as m}]
|
[pt {:keys [a b c d tx ty] :as m}]
|
||||||
(Point. (+ (* x a) (* y c) tx)
|
(let [{:keys [x y]} (point pt)]
|
||||||
(+ (* x b) (* y d) ty)))
|
(Point. (+ (* x a) (* y c) tx)
|
||||||
|
(+ (* x b) (* y d) ty))))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user