[英]How can I retrieve a canvas image and use that image in a function all within one javaScript onClick event?
This is the function that I want the canvas image retrieved into @ img.src. 这是我希望将画布图像检索到@ img.src中的功能。
function draw() {
img = new Image();
img.src = [user defined canvas image].png
fr1 = makeFrame(ctx,makeVect(400,0),makeVect(400,makeVect(0, 400));
img.onload = function(){ //<< This Im not sure of <<<
ctx.save();
newPainter = cornerSplit(imagePainter,5);
newPainter(fr1);
ctx.restore();
ctx.save();
newPainter(flipHorizLeft(fr1));
ctx.restore();
ctx.save();
newPainter(flipVertDown(fr1));
ctx.restore();
ctx.save();
newPainter(flipVertDown(flipHorizLeft(fr1)));
}
}
The canvas that the image is retrieved from, is: 'canvas2' its context is 'context2' its HTML handle is 'imageCreate' 从中检索图像的画布是:“ canvas2”,其上下文是“ context2”,其HTML句柄是“ imageCreate”
Due to how you worded your question, it is difficult to figure out exactly what you want. 由于您措辞的方式,很难弄清楚您想要的是什么。 Assuming I've guessed correctly, you would want document.getElementById("canvas2").toDataURL("image/png"), to capture the canvas's image data. 假设我猜对了,您希望document.getElementById(“ canvas2”)。toDataURL(“ image / png”)捕获画布的图像数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.