【问题标题】:Canvas blocky font rendering in JavaScriptJavaScript 中的 Canvas 块状字体渲染
【发布时间】:2015-11-13 16:44:18
【问题描述】:

我想在大画布上绘制 Blocky Font(Atari-Like)。我已经制作了一个 Canvas,它从一个 40×40 像素的小画布上复制渲染的场景。但看起来字体被小画布平滑了。 如何禁用它?

【问题讨论】:

    标签: javascript canvas html5-canvas antialiasing


    【解决方案1】:

    找到了,需要用ctx.fillText代替ctx.strokeText

    【讨论】:

      【解决方案2】:

      是你在找吗

      ctx.imageSmoothingEnabled = true; // Blurs pixels when enlarging and blend pixels when zooming out.
      
      ctx.imageSmoothingEnabled = false; // zoomed in pixels remain square with hard edges 
                                         // like in 8 bit games.
                                         // uses nearest pixel when zoomed out. 
      

      通过图像平滑,某些设备具有更好的性能。关闭此标志似乎不会造成性能损失。

      【讨论】:

        猜你喜欢
        • 2012-05-13
        • 1970-01-01
        • 2013-11-06
        • 2012-11-09
        • 2013-05-13
        • 2012-03-23
        • 2020-01-11
        • 2017-11-08
        • 2014-09-02
        相关资源
        最近更新 更多