84669 orang belajar
152542 orang belajar
20005 orang belajar
5487 orang belajar
7821 orang belajar
359900 orang belajar
3350 orang belajar
180660 orang belajar
48569 orang belajar
18603 orang belajar
40936 orang belajar
1549 orang belajar
1183 orang belajar
32909 orang belajar
canvas使用lineTo()方法绘制的斜线段,会产生锯齿
使用这个方法并没有起到预想中的效果
context.imageSmoothingEnabled = true;
请问在canvas中,一般采取什么方法做到斜线抗锯齿?
ringa_lee
let width = canvas.width,height=canvas.height;if (window.devicePixelRatio) {canvas.style.width = width + "px";canvas.style.height = height + "px";canvas.height = height * window.devicePixelRatio;canvas.width = width * window.devicePixelRatio;ctx.scale(window.devicePixelRatio, window.devicePixelRatio);}
let width = canvas.width,height=canvas.height;
if (window.devicePixelRatio) {
canvas.style.width = width + "px";
canvas.style.height = height + "px";
canvas.height = height * window.devicePixelRatio;
canvas.width = width * window.devicePixelRatio;
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
}