Skip to content

Commit 7266967

Browse files
authored
make preview accurate
1 parent e029b71 commit 7266967

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

static/extensions/TheShovel/doodlerec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,14 @@
182182
text: "fit area to stage",
183183
disableMonitor: true,
184184
},
185-
,
185+
{
186+
blockType: Scratch.BlockType.LABEL,
187+
text: "This is what the computer sees",
188+
},
186189
{
187190
opcode: "cropareapreview",
188191
blockType: Scratch.BlockType.BUTTON,
189-
text: "scan area preview",
192+
text: "Area preview",
190193
disableMonitor: true,
191194
},
192195
"---",
@@ -344,12 +347,21 @@
344347
async cropareapreview(args, util, event) {
345348
await this.clasifyThings(args, util);
346349
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();
347355
previewImage.src = img.src;
348356
previewImage.style.position = "absolute";
349357
previewImage.style.left = mx + "px";
350358
previewImage.style.top = my + "px";
351359
previewImage.style.borderRadius = "4px";
360+
previewImage.style.width = "300px";
361+
previewImage.style.height = "300px";
362+
previewImage.style.filter = "grayscale(1)";
352363
previewImage.style.zIndex = 9999;
364+
previewImage.style.imageRendering = "pixelated";
353365
document.body.appendChild(previewImage);
354366
await delay(100);
355367
let oldm = mx + my;

0 commit comments

Comments
 (0)