Merge branch 'fix-todataurl-pixelratio' of https://github.com/pronebird/konva into pronebird-fix-todataurl-pixelratio

This commit is contained in:
Anton Lavrenov 2015-04-26 07:27:28 +07:00
commit 237be44d04
2 changed files with 9 additions and 6 deletions

View File

@ -307,9 +307,9 @@
);
var cacheCanvas = this._getCachedSceneCanvas();
var ratio = context.canvas.pixelRatio;
var ratio = cacheCanvas.pixelRatio;
context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height /ratio);
context.drawImage(cacheCanvas._canvas, 0, 0, cacheCanvas.width / ratio, cacheCanvas.height / ratio);
context.restore();
},
_drawCachedHitCanvas: function(context) {
@ -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);