@@ -101,9 +101,12 @@ const tools = {
101
101
const x = window . camera . convertScreenToMapX ( canvas , cx ) ;
102
102
const y = window . camera . convertScreenToMapY ( canvas , cy ) ;
103
103
const mx = ( x % 1 + 1 ) % 1 ;
104
- const radius = 0.05 ;
104
+ const radius = toolVar . radius ;
105
105
const area = toolVar . area ;
106
106
107
+ toolVar . cx = cx ;
108
+ toolVar . cy = cy ;
109
+
107
110
toolVar . areas = area . _parentLayer . areas ;
108
111
109
112
toolVar . structure . figure . drawCircle ( mx - 1 , y , radius , area . id , 0.5 ) ;
@@ -118,14 +121,17 @@ const tools = {
118
121
toolVar . brushing = false ;
119
122
} ,
120
123
mousemove : e => {
121
- if ( ! toolVar . brushing ) return ;
122
-
123
124
const cx = ( e . clientX - canvas . offsetLeft ) * window . devicePixelRatio ;
124
125
const cy = ( e . clientY - canvas . offsetTop ) * window . devicePixelRatio ;
126
+ toolVar . cx = cx ;
127
+ toolVar . cy = cy ;
128
+
129
+ if ( ! toolVar . brushing ) return ;
130
+
125
131
const x = window . camera . convertScreenToMapX ( canvas , cx ) ;
126
132
const y = window . camera . convertScreenToMapY ( canvas , cy ) ;
127
133
const mx = ( x % 1 + 1 ) % 1 ;
128
- const radius = 0.05 ;
134
+ const radius = toolVar . radius ;
129
135
const area = toolVar . area ;
130
136
131
137
toolVar . areas = area . _parentLayer . areas ;
@@ -139,15 +145,26 @@ const tools = {
139
145
init : ( ) => {
140
146
toolVar . structure = new Structure ( 0 , new Quadtree ( 0 ) ) ;
141
147
148
+ const sizeRange = document . createElement ( "input" ) ;
149
+ sizeRange . type = "range" ;
150
+ sizeRange . min = 0 ;
151
+ sizeRange . max = 0.2 ;
152
+ sizeRange . step = 0.001 ;
153
+ sizeRange . onchange = e => {
154
+ toolVar . radius = e . target . value ;
155
+ toolVar . cx = canvas . width / 2 ;
156
+ toolVar . cy = canvas . height / 2 ;
157
+ processFrame ( ) ;
158
+ } ;
159
+ toolPropertiesDiv . appendChild ( sizeRange ) ;
160
+
142
161
const applyButton = document . createElement ( "button" ) ;
143
162
applyButton . innerText = "Apply" ;
144
163
applyButton . onclick = ( ) => {
145
164
const year = parseFloat ( presentInput . value ) ;
146
165
const change = toolVar . structure ;
147
166
const layer = toolVar . area . _parentLayer ;
148
167
149
- console . log ( "shit" ) ;
150
-
151
168
layer . createStructureByYear ( year ) ;
152
169
layer . forEachStructureAfter ( year , s => s . figure . overlap ( change . figure ) ) ;
153
170
toolVar . structure = new Structure ( 0 , new Quadtree ( 0 ) ) ;
@@ -156,6 +173,11 @@ const tools = {
156
173
toolPropertiesDiv . appendChild ( applyButton ) ;
157
174
} ,
158
175
render : force => {
176
+ const radius = toolVar . radius * window . camera . yZoom ;
177
+ ctx . beginPath ( ) ;
178
+ ctx . arc ( toolVar . cx , toolVar . cy , radius , 0 , 2 * Math . PI ) ;
179
+ ctx . stroke ( ) ;
180
+
159
181
ctx . globalAlpha = 0.4 ;
160
182
toolVar . structure . render ( toolVar . areas , canvas , ctx , window . camera , force ) ;
161
183
}
@@ -190,6 +212,8 @@ function setTool(toolId) {
190
212
} ) ;
191
213
192
214
nowTool = tool . id ;
215
+
216
+ processFrame ( ) ;
193
217
}
194
218
195
219
/**
0 commit comments