爲什麼向Group
對象添加更多行會導致如此模糊的效果?在一組中有多行模糊bug
注意,在組中具有單個線不會導致這樣的行爲。它似乎只用幾行重現。
這裏重現bug的代碼(你可以在這裏在線嘗試 - https://jsfiddle.net/90tw8mfs/,放大一點,你就會明白我說的):
var canvas = new fabric.Canvas('c');
function addFirstGroup() {
var firstLine = new fabric.Line([0, 0, 0, 100], {
strokeLineCap: 'round',
strokeWidth: 2,
stroke: '#070B7D'
});
var group = new fabric.Group([firstLine], {
left: 100,
top: 100
});
canvas.add(group);
}
function addSecondGroup() {
var firstLine = new fabric.Line([0, 0, 0, 100], {
strokeLineCap: 'round',
strokeWidth: 2,
stroke: '#070B7D'
});
var secondLine = new fabric.Line([0, 100, 100, 100], {
strokeLineCap: 'round',
strokeWidth: 2,
stroke: '#070B7D'
});
var thirdLine = new fabric.Line([100, 100, 100, 0], {
strokeLineCap: 'round',
strokeWidth: 2,
stroke: '#070B7D'
});
var group = new fabric.Group([firstLine, secondLine, thirdLine], {
left: 100,
top: 300
});
canvas.add(group);
}
addFirstGroup();
addSecondGroup();
$('#canvas-wrapper').mousewheel(function(e) {
if (e.originalEvent.deltaY < 0) {
var newZoom = canvas.getZoom() + 0.1;
} else {
var newZoom = canvas.getZoom() - 0.1;
}
canvas.setZoom(newZoom);
});
爲什麼?我該如何解決它?
向'canvas'元素添加'image-rendering:pixelated;'並不能解決問題 – FrozenHeart