阅读related articles,我尝试以像素为单位强制画布大小,指定路径的半像素以及context.translate(0.5)但我的画布线仍然模糊。
const ctx = canvas.getContext("2d");
ctx.translate(0.5, 0.5);
/* Function to draw HTML5 canvas line */
const drawPath = (startX, startY, endX, endY) => {
ctx.beginPath();
ctx.lineWidth = "1";
ctx.strokeStyle = "red";
ctx.moveTo(startX, startY);
ctx.lineTo(endX, endY);
ctx.stroke();
};
我哪里出错了怎么能让我的线条像演示中的方框边框一样清晰?