File tree Expand file tree Collapse file tree 8 files changed +26
-19
lines changed Expand file tree Collapse file tree 8 files changed +26
-19
lines changed Original file line number Diff line number Diff line change 80
80
r (/ (first (utils.bounds/->dimensions bbox)) 2 )]
81
81
[:g
82
82
[utils.svg/line [cx cy] [(+ cx r) cy]]
83
- [utils.svg/label (str (utils.length/->fixed r)) [(+ cx (/ r 2 )) cy]]
83
+ [utils.svg/label (str (utils.length/->fixed r 2 false )) [(+ cx (/ r 2 )) cy]]
84
84
[utils.svg/times [cx cy]]
85
85
[tool.views/square-handle {:x (+ cx r)
86
86
:y cy
Original file line number Diff line number Diff line change 19
19
[]
20
20
{:icon " ellipse"
21
21
:label (t [::name " Ellipse" ])
22
- :description (t [::description
22
+ :description (t [::description
23
23
" The <ellipse> element is an SVG basic shape, used to create
24
24
ellipses based on a center coordinate, and both their x and
25
25
y radius." ])
87
87
[:g ::edit-handles
88
88
[utils.svg/times [cx cy]]
89
89
[utils.svg/line [cx cy] [(+ cx rx) cy]]
90
- [utils.svg/label (str (utils.length/->fixed rx)) [(+ cx (/ rx 2 )) cy]]
90
+ [utils.svg/label (str (utils.length/->fixed rx 2 false )) [(+ cx (/ rx 2 )) cy]]
91
91
[utils.svg/line [cx cy] [cx (- cy ry)]]
92
- [utils.svg/label (str (utils.length/->fixed ry)) [cx (- cy (/ ry 2 ))]]
92
+ [utils.svg/label (str (utils.length/->fixed ry 2 false )) [cx (- cy (/ ry 2 ))]]
93
93
(map (fn [handle]
94
94
^{:key (:id handle)}
95
95
[tool.views/square-handle
Original file line number Diff line number Diff line change 12
12
[renderer.utils.bounds :as utils.bounds]
13
13
[renderer.utils.element :as utils.element]
14
14
[renderer.utils.i18n :refer [t]]
15
- [renderer.utils.length :as utils.length]
15
+ [renderer.utils.length :as utils.length]
16
16
[renderer.utils.svg :as utils.svg]))
17
17
18
18
(derive :line ::element.hierarchy/shape )
21
21
[]
22
22
{:icon " line"
23
23
:label (t [::name " Line" ])
24
- :description (t [::description
25
- " The <line> element is an SVG basic shape
24
+ :description (t [::description
25
+ " The <line> element is an SVG basic shape
26
26
used to create a line connecting two points." ])
27
27
:attrs [:stroke
28
28
:stroke-width
75
75
[:title {:key (str id " -title" )} (name id)]]
76
76
(when is-active
77
77
[utils.svg/label
78
- (string/join " " [(utils.length/->fixed x) (utils.length/->fixed y)])
78
+ (string/join " " [(utils.length/->fixed x 2 false )
79
+ (utils.length/->fixed y 2 false )])
79
80
[(- x margin) (+ y margin)]
80
81
" end" ])]))
81
82
[{:x x1
Original file line number Diff line number Diff line change 84
84
(when is-active
85
85
[utils.svg/label
86
86
(->> [x y]
87
- (mapv utils.length/->fixed)
87
+ (mapv #( utils.length/->fixed % 2 false ) )
88
88
(string/join " " ))
89
89
[(- x margin) (+ y margin)]
90
90
" end" ])]))
Original file line number Diff line number Diff line change 425
425
x (+ min-x (/ (- max-x min-x) 2 ))
426
426
y (+ y2 (/ (+ (/ theme.db/handle-size 2 ) 15 ) zoom))
427
427
[w h] (utils.bounds/->dimensions bbox)
428
- text (str (utils.length/->fixed w) " x " (utils.length/->fixed h))]
428
+ text (str (utils.length/->fixed w 2 false )
429
+ " x "
430
+ (utils.length/->fixed h 2 false ))]
429
431
[utils.svg/label text [x y]]))
430
432
431
433
(m/=> area-label [:-> number? BBox any?])
436
438
[min-x min-y max-x] bbox
437
439
x (+ min-x (/ (- max-x min-x) 2 ))
438
440
y (+ min-y (/ (- -15 (/ theme.db/handle-size 2 )) zoom))
439
- text (str (utils.length/->fixed area) " px²" )]
441
+ text (str (utils.length/->fixed area 2 false ) " px²" )]
440
442
[utils.svg/label text [x y]])))
441
443
442
444
(defmethod tool.hierarchy /render :transform
Original file line number Diff line number Diff line change 70
70
[utils.svg/line [x1 y1] [(+ x1 (/ 30 zoom)) y1]]
71
71
72
72
[utils.svg/label
73
- (str (utils.length/->fixed straight-angle) " °" )
73
+ (str (utils.length/->fixed straight-angle 2 false ) " °" )
74
74
[(+ x1 (/ 40 zoom)) y1]
75
75
" start" ]
76
76
77
77
[utils.svg/label
78
- (-> hypotenuse js/parseFloat utils.length/->fixed str)
78
+ (-> hypotenuse js/parseFloat ( utils.length/->fixed 2 false ) str)
79
79
[(/ (+ x1 x2) 2 ) (/ (+ y1 y2) 2 )]]])))
80
80
81
81
(defmethod tool.hierarchy /snapping-points :measure
Original file line number Diff line number Diff line change 25
25
:style {:min-width " 100px" }
26
26
:dir " ltr" }
27
27
[:div.flex.justify-between
28
- [:span.mr-1 " X:" ] [:span (utils.length/->fixed x)]]
28
+ [:span.mr-1 " X:" ] [:span (utils.length/->fixed x 2 false )]]
29
29
[:div.flex.justify-between
30
- [:span.mr-1 " Y:" ] [:span (utils.length/->fixed y)]]]))
30
+ [:span.mr-1 " Y:" ] [:span (utils.length/->fixed y 2 false )]]]))
31
31
32
32
(defn zoom-options []
33
33
[{:label (t [::zoom-set-50 " Set to 50%" ])
115
115
116
116
(defn zoom-input
117
117
[zoom]
118
- (let [value (utils.length/->fixed (* 100 zoom) (zoom-decimal-points zoom))]
118
+ (let [value (utils.length/->fixed (* 100 zoom) (zoom-decimal-points zoom) false )]
119
119
[:input.form-element.overlay.text-right.font-mono.p-1
120
120
{:key zoom
121
121
:aria-label " Zoom"
Original file line number Diff line number Diff line change 65
65
66
66
(m/=> ->fixed [:function
67
67
[:-> number? number?]
68
- [:-> number? integer? number?]])
68
+ [:-> number? integer? number?]
69
+ [:-> number? integer? boolean? number?]])
69
70
(defn ->fixed
70
71
([v]
71
72
(->fixed v 3 ))
72
73
([v precision]
73
- (-> (.toFixed v precision)
74
- (js/parseFloat ))))
74
+ (->fixed v precision true ))
75
+ ([v precision remove-trailing-zeros]
76
+ (cond-> (.toFixed v precision)
77
+ remove-trailing-zeros
78
+ (js/parseFloat ))))
75
79
76
80
(m/=> transform [:-> [:or string? number? nil?] ifn? [:* any?] string?])
77
81
(defn transform
You can’t perform that action at this time.
0 commit comments