Add pixel ratio support for snapshots

This commit is contained in:
Andrej Mihajlov 2015-04-16 19:22:46 +02:00
parent 3eb87ece05
commit 29f85d1a82
2 changed files with 7 additions and 4 deletions

View File

@ -1391,7 +1391,7 @@
canvas = new Konva.SceneCanvas({
width: config.width || this.getWidth() || (stage ? stage.getWidth() : 0),
height: config.height || this.getHeight() || (stage ? stage.getHeight() : 0),
pixelRatio: 1
pixelRatio: config.pixelRatio
}),
context = canvas.getContext();

View File

@ -235,7 +235,7 @@
canvas = new Konva.SceneCanvas({
width: config.width || this.getWidth(),
height: config.height || this.getHeight(),
pixelRatio: 1
pixelRatio: config.pixelRatio
}),
_context = canvas.getContext()._context,
layers = this.children;
@ -246,11 +246,14 @@
function drawLayer(n) {
var layer = layers[n],
layerUrl = layer.toDataURL(),
layerUrl = layer.toDataURL({
pixelRatio: config.pixelRatio
}),
pixelRatio = canvas.pixelRatio,
imageObj = new Konva.window.Image();
imageObj.onload = function() {
_context.drawImage(imageObj, 0, 0);
_context.drawImage(imageObj, 0, 0, imageObj.width / pixelRatio, imageObj.height / pixelRatio);
if(n < layers.length - 1) {
drawLayer(n + 1);