【问题标题】:jCanvas imageSmoothingEnabled not workingjCanvas imageSmoothingEnabled 不起作用
【发布时间】:2014-11-14 09:56:15
【问题描述】:

所以我正在尝试使用 jCanvas 在 html 中构建带有像素艺术的游戏。但是,当我尝试禁用 imageSmoothing 以使像素保持清晰时,什么也没有发生。

$(function() {
    $('canvas').drawImage({
        source: 'http://i.imgur.com/Y2o59.png',
        x:400, y:250,
        width: 160, height: 160,
        imageSmoothingEnabled: false,
    });
});

编辑:添加了随机像素图,使其更易于测试。

【问题讨论】:

    标签: html canvas jcanvas


    【解决方案1】:

    想通了。

    首先,它的imageSmoothing: false,不是imageSmoothingEnabled: false。 其次,您仍然需要在上下文中启用平滑,如下所示:

    var ctxbgd = document.getElementById('background').getContext("2d");
        ctxbgd.imageSmoothingEnabled = false;
        ctxbgd.webkitImageSmoothingEnabled = false;
        ctxbgd.mozImageSmoothingEnabled = false;
    

    那里,没有平滑。

    【讨论】:

      猜你喜欢
      • 2019-07-04
      • 2015-08-06
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 2013-01-14
      • 2012-03-17
      • 2013-04-26
      • 2013-12-25
      相关资源
      最近更新 更多