mirror of
https://github.com/penpot/penpot.git
synced 2025-05-09 13:16:37 +02:00
Fix bugs on scale and rotate opetation over matrix.
This commit is contained in:
parent
5df6e6397d
commit
9bfe24e477
1 changed files with 12 additions and 11 deletions
|
@ -62,25 +62,26 @@
|
||||||
y (:y center)
|
y (:y center)
|
||||||
cos (mth/cos angle)
|
cos (mth/cos angle)
|
||||||
sin (mth/sin angle)
|
sin (mth/sin angle)
|
||||||
nsin (mth/neg sin)
|
nsin (- sin)
|
||||||
tx (+ (- x (* x cos)) (* y sin))
|
tx (- x (+ (* x cos)) (* y sin))
|
||||||
ty (- (- y (* x sin)) (* y cos))
|
ty (- y (- (* x sin)) (* y cos))
|
||||||
a (+ (* cos (:a m)) (* sin (:b m)))
|
a (+ (* cos (:a m)) (* sin (:b m)))
|
||||||
b (+ (* nsin (:a m)) (* cos (:b m)))
|
b (+ (* nsin (:a m)) (* cos (:b m)))
|
||||||
c (+ (* cos (:c m)) (* sin (:d m)))
|
c (+ (* cos (:c m)) (* sin (:d m)))
|
||||||
d (+ (* nsin (:c m)) (* cos (:d m)))
|
d (+ (* nsin (:c m)) (* cos (:d m)))
|
||||||
tx' (+ (:tx m) (* tx (:a m)) (* tx (:b m)))
|
tx' (+ (:tx m) (* tx (:a m)) (* ty (:b m)))
|
||||||
ty' (+ (:ty m) (* tx (:c m)) (* ty (:d m)))]
|
ty' (+ (:ty m) (* tx (:c m)) (* ty (:d m)))]
|
||||||
(Matrix. a b c d tx ty))))
|
(Matrix. a b c d tx' ty'))))
|
||||||
|
|
||||||
(defn scale
|
(defn scale
|
||||||
"Apply scale transformation to the matrix."
|
"Apply scale transformation to the matrix."
|
||||||
[m v]
|
([m v] (scale m v v))
|
||||||
(assoc m
|
([m x y]
|
||||||
:a (* (:a m) v)
|
(assoc m
|
||||||
:c (* (:c m) v)
|
:a (* (:a m) x)
|
||||||
:b (* (:b m) v)
|
:c (* (:c m) x)
|
||||||
:d (* (:d m) v)))
|
:b (* (:b m) y)
|
||||||
|
:d (* (:d m) y))))
|
||||||
|
|
||||||
(defn translate
|
(defn translate
|
||||||
"Apply translate transformation to the matrix."
|
"Apply translate transformation to the matrix."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue