mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
Add pixel ratio support for snapshots
This commit is contained in:
parent
3eb87ece05
commit
29f85d1a82
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user