mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 17:46:11 +02:00
✨ Adds method to-fixed
to math
Changes matrix/toString to use `to-fixed`
This commit is contained in:
parent
57a569a07a
commit
1b7ea6ed53
2 changed files with 13 additions and 17 deletions
|
@ -27,23 +27,13 @@
|
|||
^double f]
|
||||
Object
|
||||
(toString [_]
|
||||
#?(:clj
|
||||
(dm/fmt "matrix(%, %, %, %, %, %)"
|
||||
(mth/precision a precision)
|
||||
(mth/precision b precision)
|
||||
(mth/precision c precision)
|
||||
(mth/precision d precision)
|
||||
(mth/precision e precision)
|
||||
(mth/precision f precision))
|
||||
|
||||
:cljs
|
||||
(dm/fmt "matrix(%, %, %, %, %, %)"
|
||||
(.toFixed a precision)
|
||||
(.toFixed b precision)
|
||||
(.toFixed c precision)
|
||||
(.toFixed d precision)
|
||||
(.toFixed e precision)
|
||||
(.toFixed f precision)))))
|
||||
(dm/fmt "matrix(%, %, %, %, %, %)"
|
||||
(mth/to-fixed a precision)
|
||||
(mth/to-fixed b precision)
|
||||
(mth/to-fixed c precision)
|
||||
(mth/to-fixed d precision)
|
||||
(mth/to-fixed e precision)
|
||||
(mth/to-fixed f precision))))
|
||||
|
||||
(defn matrix?
|
||||
"Return true if `v` is Matrix instance."
|
||||
|
|
|
@ -127,6 +127,12 @@
|
|||
(let [d (pow 10 n)]
|
||||
(/ (round (* v d)) d))))
|
||||
|
||||
(defn to-fixed
|
||||
"Returns a string representing the given number, using fixed precision."
|
||||
[v n]
|
||||
#?(:cljs (.toFixed ^js v n)
|
||||
:clj (str (precision v n))))
|
||||
|
||||
(defn radians
|
||||
"Converts degrees to radians."
|
||||
[degrees]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue