因此,我正在尝试使用jCanvas在html中构建一个带有像素艺术的游戏。但是,当我尝试禁用imageSmoothing以保持像素清晰时,什么也没有发生。
$(function() {
$('canvas').drawImage({
source: 'http://i.imgur.com/Y2o59.png',
x:400, y:250,
width: 160, height: 160,
imageSmoothingEnabled: false,
});
});编辑:添加了随机的像素图片,使其更容易测试。
发布于 2014-11-14 09:56:16
我想通了。
首先,它的imageSmoothing: false,而不是imageSmoothingEnabled: false。其次,您仍然需要在上下文中启用平滑,如下所示:
var ctxbgd = document.getElementById('background').getContext("2d");
ctxbgd.imageSmoothingEnabled = false;
ctxbgd.webkitImageSmoothingEnabled = false;
ctxbgd.mozImageSmoothingEnabled = false;在那里,没有平滑。
https://stackoverflow.com/questions/26902217
复制相似问题