首頁  >  問答  >  主體

html5 - canvas斜线如何做到抗锯齿?

canvas使用lineTo()方法绘制的斜线段,会产生锯齿

使用这个方法并没有起到预想中的效果

context.imageSmoothingEnabled = true;

请问在canvas中,一般采取什么方法做到斜线抗锯齿?

ringa_leeringa_lee2717 天前1078

全部回覆(1)我來回復

  • 大家讲道理

    大家讲道理2017-04-17 13:50:31

    let width = canvas.width,height=canvas.height;
    if (window.devicePixelRatio) {
    canvas.style.width = width + "px";
    canvas.style.style. height + "px";
    canvas.height = 高度* window.devicePixelRatio;
    canvas.width = 寬度* window.devicePixelRatio;
    ctx.scale(window.devicePixeldio, windownixel; >}

    回覆
    0
  • 取消回覆