我想繪製一幅圖像到畫布上,然後允許用戶通過sketch.js在其上繪製一些草圖。現在的情況是:如何在畫布上同時繪製圖像和草圖
1.the image has been drawn on the canvas successfully
2. but when my mouse over the canvas, then image disappeared, and the canvas shows empty
3. when I dragged the mouse, some sketch shows on the empty canvas(the sketch looks correct)
所以,我已經使兩個功能都正確,但我對兩者之間的部分感到困惑。我希望在畫布上繪製草圖,並在其上放置圖像。這裏是我的代碼:
的index.html:
<canvas id="mysketch" width="578" height="400" style="margin: 0px; "></canvas>
canvas.js:
var mysketch = jQuery("#mysketch");
// draw the captured image to canvas
var displayImage = function() {
var context = mysketch.get(0).getContext("2d");
var image = new Image();
image.onload = function() {
context.drawImage(image, 0, 0);
}
// prepend the required image info again
image.src = dataURL;
// call sketch.js to draw sketch on the canvas
mysketch.sketch({defaultColor: "#ff0"});
}
你確定沒有'懸停'事件的一些CSS或其他功能? – Hank