0
我可以創建線條,但是我想創建線條,就像您可以改變線條的方向和線的大小,就像這個鏈接中的http://devfiles.myopera.com/articles/649/example5.html一樣。HTML5畫布線問題
這是我的代碼
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
$("canvas").mousedown(function(e) {
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
var a = x;
var b = y;
context.beginPath();
context.lineWidth = 2;
context.lineCap = "round";
context.moveTo(a, b);
$("canvas").mousemove(function(e) {
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
context.lineTo(x, y);
context.stroke();
});
$("canvas").mouseup(function(e) {
$("canvas").unbind("mousemove").unbind("mouseup");
});
});
您也可以看看從。 http://jsfiddle.net/nSnDC/我該如何解決呢