|
182 | 182 | text: "fit area to stage", |
183 | 183 | disableMonitor: true, |
184 | 184 | }, |
185 | | - , |
| 185 | + { |
| 186 | + blockType: Scratch.BlockType.LABEL, |
| 187 | + text: "This is what the computer sees", |
| 188 | + }, |
186 | 189 | { |
187 | 190 | opcode: "cropareapreview", |
188 | 191 | blockType: Scratch.BlockType.BUTTON, |
189 | | - text: "scan area preview", |
| 192 | + text: "Area preview", |
190 | 193 | disableMonitor: true, |
191 | 194 | }, |
192 | 195 | "---", |
|
344 | 347 | async cropareapreview(args, util, event) { |
345 | 348 | await this.clasifyThings(args, util); |
346 | 349 | const previewImage = document.createElement("img"); |
| 350 | + cropArea.width = 28; |
| 351 | + cropArea.height = 28; |
| 352 | + ctx.clearRect(0, 0, cropArea.width, cropArea.height); |
| 353 | + ctx.drawImage(img, 0, 0, cropArea.width, cropArea.height); |
| 354 | + img.src = cropArea.toDataURL(); |
347 | 355 | previewImage.src = img.src; |
348 | 356 | previewImage.style.position = "absolute"; |
349 | 357 | previewImage.style.left = mx + "px"; |
350 | 358 | previewImage.style.top = my + "px"; |
351 | 359 | previewImage.style.borderRadius = "4px"; |
| 360 | + previewImage.style.width = "300px"; |
| 361 | + previewImage.style.height = "300px"; |
| 362 | + previewImage.style.filter = "grayscale(1)"; |
352 | 363 | previewImage.style.zIndex = 9999; |
| 364 | + previewImage.style.imageRendering = "pixelated"; |
353 | 365 | document.body.appendChild(previewImage); |
354 | 366 | await delay(100); |
355 | 367 | let oldm = mx + my; |
|
0 commit comments