File tree Expand file tree Collapse file tree 18 files changed +74
-45
lines changed Expand file tree Collapse file tree 18 files changed +74
-45
lines changed Original file line number Diff line number Diff line change 5
5
:aliased-namespace-symbol {:level :warning }
6
6
:condition-always-true {:level :warning }
7
7
:docstring-leading-trailing-whitespace {:level :warning }
8
- :equals-float {:level :warning }
9
8
:def-fn {:level :warning }
10
9
:reduce-without-init {:level :warning }
11
10
:keyword-binding {:level :warning }
Original file line number Diff line number Diff line change 33
33
[renderer.toolbar.status :as toolbar.status]
34
34
[renderer.toolbar.tools :as toolbar.tools]
35
35
[renderer.tree.views :as tree.views]
36
+ [renderer.utils.length :as utils.length]
36
37
[renderer.views :as views]
37
38
[renderer.window.views :as window.views]))
38
39
39
40
(defn coll->str
40
41
[coll]
41
- (str " [" (string/join " " (map #( .toFixed % 2 ) coll)) " ]" ))
42
+ (str " [" (string/join " " (map utils.length/to-fixed coll)) " ]" ))
42
43
43
44
(defn map->str
44
45
[m]
45
46
(interpose " , " (map (fn [[k v]]
46
47
^{:key k}
47
48
[:span (str (name k) " : " (if (number? v)
48
- (.toFixed v 3 )
49
+ (utils.length/to-fixed v )
49
50
(coll->str v)))]) m)))
50
51
51
52
(defn debug-rows
Original file line number Diff line number Diff line change 82
82
b (nth points 1 )
83
83
c (nth points 2 )
84
84
d (str
85
- " M" (.toFixed (first a) 2 ) " ," (.toFixed (second a) 2 )
86
- " Q" (.toFixed (first b) 2 ) " ," (.toFixed (second b) 2 )
87
- " " (.toFixed (matrix.stats/mean [(first b) (first c)]) 2 ) " ,"
88
- (.toFixed (matrix.stats/mean [(second b) (second c)]) 2 ) " T" )]
85
+ " M" (utils.length/to-fixed (first a)) " ," (utils.length/to-fixed (second a))
86
+ " Q" (utils.length/to-fixed (first b)) " ," (utils.length/to-fixed (second b))
87
+ " " (utils.length/to-fixed (matrix.stats/mean [(first b) (first c)])) " ,"
88
+ (utils.length/to-fixed (matrix.stats/mean [(second b) (second c)])) " T" )]
89
89
(reduce-kv
90
90
(fn [result index]
91
91
(if (or (= len (inc index)) (< index 2 ))
92
92
result
93
93
(let [a (nth points index)
94
94
b (nth points (inc index))]
95
95
(str result
96
- (.toFixed (matrix.stats/mean [(first a) (first b)]) 2 )
96
+ (utils.length/to-fixed (matrix.stats/mean [(first a) (first b)]))
97
97
" ,"
98
- (.toFixed (matrix.stats/mean [(second a) (second b)]) 2 )
98
+ (utils.length/to-fixed (matrix.stats/mean [(second a) (second b)]))
99
99
" " )))) d points)))))
100
100
101
101
(def partition-to-px
Original file line number Diff line number Diff line change 77
77
r (/ (first (utils.bounds/->dimensions bbox)) 2 )]
78
78
[:g
79
79
[utils.svg/line [cx cy] [(+ cx r) cy]]
80
- [utils.svg/label (str (.toFixed r 3 )) [(+ cx (/ r 2 )) cy]]
80
+ [utils.svg/label (str (utils.length/to-fixed r )) [(+ cx (/ r 2 )) cy]]
81
81
[utils.svg/times [cx cy]]
82
82
[tool.views/square-handle {:x (+ cx r)
83
83
:y cy
Original file line number Diff line number Diff line change 84
84
[:g ::edit-handles
85
85
[utils.svg/times [cx cy]]
86
86
[utils.svg/line [cx cy] [(+ cx rx) cy]]
87
- [utils.svg/label (str (.toFixed rx 3 )) [(+ cx (/ rx 2 )) cy]]
87
+ [utils.svg/label (str (utils.length/to-fixed rx)) [(+ cx (/ rx 2 )) cy]]
88
88
[utils.svg/line [cx cy] [cx (- cy ry)]]
89
- [utils.svg/label (str (.toFixed ry 3 )) [cx (- cy (/ ry 2 ))]]
89
+ [utils.svg/label (str (utils.length/to-fixed ry)) [cx (- cy (/ ry 2 ))]]
90
90
(map (fn [handle]
91
91
^{:key (:id handle)}
92
92
[tool.views/square-handle
Original file line number Diff line number Diff line change 72
72
[:title {:key (str id " -title" )} (name id)]]
73
73
(when is-active
74
74
[utils.svg/label
75
- (string/join " " [(.toFixed x 3 ) (.toFixed y 3 )])
75
+ (string/join " " [(utils.length/to-fixed x ) (utils.length/to-fixed y )])
76
76
[(- x margin) (+ y margin)]
77
77
" end" ])]))
78
78
[{:x x1
Original file line number Diff line number Diff line change 83
83
:element (:id el)}]
84
84
(when is-active
85
85
[utils.svg/label
86
- (string/join " " [(.toFixed x 3 ) (.toFixed y 3 )])
86
+ (->> [(utils.length/to-fixed x) (utils.length/to-fixed y)]
87
+ (string/join " " ))
87
88
[(- x margin) (+ y margin)]
88
89
" end" ])]))
89
90
(utils.attribute/points->vec (-> el :attrs :points )))]))
Original file line number Diff line number Diff line change 21
21
[renderer.tool.views :as tool.views]
22
22
[renderer.utils.bounds :as utils.bounds :refer [BBox]]
23
23
[renderer.utils.element :as utils.element]
24
+ [renderer.utils.length :as utils.length]
24
25
[renderer.utils.math :refer [Vec2]]
25
26
[renderer.utils.svg :as utils.svg]))
26
27
421
422
x (+ min-x (/ (- max-x min-x) 2 ))
422
423
y (+ y2 (/ (+ (/ theme.db/handle-size 2 ) 15 ) zoom))
423
424
[w h] (utils.bounds/->dimensions bbox)
424
- text (str (.toFixed w 3 ) " x " (.toFixed h 3 ))]
425
+ text (str (utils.length/to-fixed w ) " x " (utils.length/to-fixed h ))]
425
426
[utils.svg/label text [x y]]))
426
427
427
428
(m/=> area-label [:-> number? BBox any?])
432
433
[min-x min-y max-x] bbox
433
434
x (+ min-x (/ (- max-x min-x) 2 ))
434
435
y (+ min-y (/ (- -15 (/ theme.db/handle-size 2 )) zoom))
435
- text (str (.toFixed area 3 ) " px²" )]
436
+ text (str (utils.length/to-fixed area) " px²" )]
436
437
[utils.svg/label text [x y]])))
437
438
438
439
(defmethod tool.hierarchy /render :transform
Original file line number Diff line number Diff line change 6
6
[renderer.element.handlers :as element.handlers]
7
7
[renderer.history.handlers :as history.handlers]
8
8
[renderer.tool.handlers :as tool.handlers]
9
- [renderer.tool.hierarchy :as tool.hierarchy]))
9
+ [renderer.tool.hierarchy :as tool.hierarchy]
10
+ [renderer.utils.length :as utils.length]))
10
11
11
12
(derive :circle ::tool.hierarchy/element )
12
13
35
36
[db _e]
36
37
(let [offset (or (:nearest-neighbor-offset db) (:adjusted-pointer-offset db))
37
38
position (or (:point (:nearest-neighbor db)) (:adjusted-pointer-pos db))
38
- radius (.toFixed (matrix/distance position offset) 3 )
39
+ radius (utils.length/to-fixed (matrix/distance position offset))
39
40
id (:id (first (element.handlers/selected db)))]
40
41
(element.handlers/update-el db id #(assoc-in % [:attrs :r ] (str radius)))))
41
42
Original file line number Diff line number Diff line change 5
5
[renderer.element.handlers :as element.handlers]
6
6
[renderer.history.handlers :as history.handlers]
7
7
[renderer.tool.handlers :as tool.handlers]
8
- [renderer.tool.hierarchy :as tool.hierarchy]))
8
+ [renderer.tool.hierarchy :as tool.hierarchy]
9
+ [renderer.utils.length :as utils.length]))
9
10
10
11
(derive :ellipse ::tool.hierarchy/element )
11
12
23
24
(let [[offset-x offset-y] (or (:nearest-neighbor-offset db)
24
25
(:adjusted-pointer-offset db))
25
26
[x y] (or (:point (:nearest-neighbor db)) (:adjusted-pointer-pos db))
26
- rx (.toFixed (abs (- x offset-x)) 3 )
27
- ry (.toFixed (abs (- y offset-y)) 3 )]
27
+ rx (utils.length/to-fixed (abs (- x offset-x)))
28
+ ry (utils.length/to-fixed (abs (- y offset-y)))]
28
29
{:rx (cond-> rx lock-ratio (min ry))
29
30
:ry (cond-> ry lock-ratio (min rx))}))
30
31
You can’t perform that action at this time.
0 commit comments