我正在白色背景的 Canvas 上绘制图像。我想在图像上绘制边框,但无法这样做。这是我的代码:
var canvas = parent.document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
var context = canvas.getContext('2d');
context.fillStyle = "black";
context.font = "50px Arial";
//context.fillText(chartId, canvas.width-200, 50);
context.drawImage(image, 0, 0);
context.fillStyle = "#000000";
context.rect(0,0,canvas.width,canvas.height);
context.globalCompositeOperation = "destination-over";
context.fillStyle = "#FFFFFF";
但是当我下载此图像时,我没有看到任何边框。
最佳答案
你忘了抚摸你的直肠。
context.stroke();
关于javascript - 无法在 Canvas 上绘制矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31041833/