【发布时间】:2015-03-09 20:08:19
【问题描述】:
我正在使用 html5 和 javascript 在画布上进行绘图。
如果我不手动设置画布宽度和高度(保持默认),我的绘图效果很好。
但是,当我从 css 或 javascript 设置画布大小时,我的绘图看起来像扭曲了。线条开始稍微偏离线条,线条看起来扭曲了。
这是mousedown事件的代码。
if (mouseDown)
{
previousX = currentX;
previousY = currentY;
currentX = e.clientX - canvas.offsetLeft;
currentY = e.clientY - canvas.offsetTop;
ctx.beginPath();
ctx.moveTo(previousX, previousY);
ctx.lineTo(currentX, currentY);
ctx.strokeStyle = color;
ctx.lineWidth = y;
ctx.stroke();
ctx.closePath();
}
【问题讨论】:
标签: javascript html canvas