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) {
|
if(pixelRatio !== 1) {
|
||||||
this.getContext().scale(pixelRatio, pixelRatio);
|
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.afterDrawFunc = undefined;
|
||||||
this.canvas = new Kinetic.SceneCanvas();
|
this.canvas = new Kinetic.SceneCanvas();
|
||||||
this.canvas.getElement().style.position = 'absolute';
|
this.canvas.getElement().style.position = 'absolute';
|
||||||
this.hitCanvas = new Kinetic.HitCanvas(0, 0);
|
this.hitCanvas = new Kinetic.HitCanvas();
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
Kinetic.Container.call(this, config);
|
Kinetic.Container.call(this, config);
|
||||||
|
|||||||
@@ -760,6 +760,8 @@
|
|||||||
}
|
}
|
||||||
context = canvas.getContext();
|
context = canvas.getContext();
|
||||||
context.save();
|
context.save();
|
||||||
|
canvas._counterPixelRatio();
|
||||||
|
|
||||||
if(x || y) {
|
if(x || y) {
|
||||||
context.translate(-1 * x, -1 * y);
|
context.translate(-1 * x, -1 * y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -563,7 +563,7 @@
|
|||||||
this.attrs.container.appendChild(this.content);
|
this.attrs.container.appendChild(this.content);
|
||||||
|
|
||||||
this.bufferCanvas = new Kinetic.SceneCanvas();
|
this.bufferCanvas = new Kinetic.SceneCanvas();
|
||||||
this.hitCanvas = new Kinetic.HitCanvas(0, 0);
|
this.hitCanvas = new Kinetic.HitCanvas();
|
||||||
|
|
||||||
this._resizeDOM();
|
this._resizeDOM();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user