|
160 | 160 | prevY = y; |
161 | 161 | } |
162 | 162 |
|
163 | | - const canvasDrawing = true; |
| 163 | + const canvasDrawing = false; |
164 | 164 |
|
165 | 165 | if (canvasDrawing) { |
166 | 166 | if (x === prevX && y === prevY) { |
|
250 | 250 | // No block found in cache and on server |
251 | 251 | CATMAID.msg('success', 'A new block is created, because no existing block is found'); |
252 | 252 | // TODO: Init new block |
253 | | - // const backgroundValue = 0; |
254 | | - const blockData = nj.zeros(blockSize, dataType); |
255 | | - block = new nj.NdArray(blockData) |
256 | | - .transpose(...this.dataLayer.tileSource.sliceDims); |
| 253 | + const backgroundValue = 0; |
| 254 | + block = nj.zeros(blockSize, dataType); |
| 255 | + block.assign(backgroundValue, false); |
| 256 | + // TODO: Needed? |
| 257 | + block = block.transpose(...this.dataLayer.tileSource.sliceDims); |
257 | 258 | } |
258 | 259 |
|
259 | 260 | // Update block data and write to cache if not already there. The block is |
260 | 261 | // a nj.NdArray instance. |
261 | | - |
| 262 | + const relVoxelPos = [ |
| 263 | + Math.floor(voxelPosX - blockCoord[0] * blockSize[0]), |
| 264 | + Math.floor(voxelPosY - blockCoord[1] * blockSize[1]), |
| 265 | + Math.floor(voxelPosZ - blockCoord[2] * blockSize[2]) |
| 266 | + ]; |
| 267 | + |
| 268 | + // Draw a coarse circle |
| 269 | + const halfBrushSize = Math.floor(this.brushSize / 2.0); |
| 270 | + const sqBrushSize = halfBrushSize * halfBrushSize; |
| 271 | + for (let x = -halfBrushSize; x <= halfBrushSize; x++) { |
| 272 | + for (let y = -halfBrushSize; y <= halfBrushSize; y++) { |
| 273 | + const sqDist = x * x + y * y; |
| 274 | + if (sqDist <= sqBrushSize) { |
| 275 | + block.set(relVoxelPos[0] + x, relVoxelPos[1] + y, relVoxelPos[2], this.value); |
| 276 | + } |
| 277 | + } |
| 278 | + } |
262 | 279 |
|
263 | 280 | // Write block back to server. This is done asynchronously in regular |
264 | 281 | // intervald (if changes happen). |
|
0 commit comments