mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 09:07:30 +08:00
added counter pixel ratio method so that drawings aren't double scaled when using toDataUrl and toImage
This commit is contained in:
@@ -187,6 +187,13 @@
|
||||
if(pixelRatio !== 1) {
|
||||
this.getContext().scale(pixelRatio, pixelRatio);
|
||||
}
|
||||
},
|
||||
_counterPixelRatio: function() {
|
||||
var pixelRatio = Kinetic.Canvas.pixelRatio;
|
||||
if(pixelRatio !== 1) {
|
||||
pixelRatio = 1 / pixelRatio;
|
||||
this.getContext().scale(pixelRatio, pixelRatio);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
this.afterDrawFunc = undefined;
|
||||
this.canvas = new Kinetic.SceneCanvas();
|
||||
this.canvas.getElement().style.position = 'absolute';
|
||||
this.hitCanvas = new Kinetic.HitCanvas(0, 0);
|
||||
this.hitCanvas = new Kinetic.HitCanvas();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Container.call(this, config);
|
||||
|
||||
@@ -760,6 +760,8 @@
|
||||
}
|
||||
context = canvas.getContext();
|
||||
context.save();
|
||||
canvas._counterPixelRatio();
|
||||
|
||||
if(x || y) {
|
||||
context.translate(-1 * x, -1 * y);
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@
|
||||
this.attrs.container.appendChild(this.content);
|
||||
|
||||
this.bufferCanvas = new Kinetic.SceneCanvas();
|
||||
this.hitCanvas = new Kinetic.HitCanvas(0, 0);
|
||||
this.hitCanvas = new Kinetic.HitCanvas();
|
||||
|
||||
this._resizeDOM();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user