Chrome的Canvas实现中存在一个已知错误,其中对lineTo的连续调用有时会丢弃角落处的像素:http://jsfiddle.net/rPJBr/2/
var cx = document.getElementById('c').getContext('2d');
cx.beginPath();
cx.moveTo(200.5, 200.5);
cx.lineTo(200.5, 100.5);
cx.lineTo(100.5, 100.5);
cx.stroke();
这是一张图片,放大了win7上Chrome 24的行为
此处已记录错误:http://code.google.com/p/chromium/issues/detail?id=137465
此错误是否有已知的解决方法?
答案 0 :(得分:0)
if(windows.chrome) {
var p = CanvasRenderingContext2D.prototype;
p.origLineTo = p.lineTo;
p.lineTo = function(x, y) {
this.fillRect(x - 0.5, y - 0.5, 1, 1);
return this.origLineTo(x, y);
};
p.origMoveTo = p.moveTo;
p.moveTo = function(x, y) {
this.fillRect(x - 0.5, y - 0.5, 1, 1);
return this.origMoveTo(x, y);
};
}