mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 19:07:59 +08:00
fixed up stage toImage() translation problem
This commit is contained in:
35
src/Stage.js
35
src/Stage.js
@@ -182,20 +182,12 @@
|
|||||||
* is very high quality
|
* is very high quality
|
||||||
*/
|
*/
|
||||||
toDataURL: function(config) {
|
toDataURL: function(config) {
|
||||||
var mimeType = config && config.mimeType ? config.mimeType : null;
|
config = config || {};
|
||||||
var quality = config && config.quality ? config.quality : null;
|
var mimeType = config.mimeType || null, quality = config.quality || null, x = config.x || 0, y = config.y || 0, canvas = new Kinetic.SceneCanvas(config.width || this.getWidth(), config.height || this.getHeight()), context = canvas.getContext(), layers = this.children;
|
||||||
/*
|
|
||||||
* need to create a canvas element rather than using the hit canvas
|
if(x || y) {
|
||||||
* because this method is asynchonous which means that other parts of the
|
context.translate(-1 * x, -1 * y);
|
||||||
* code could modify the hit canvas before it's finished
|
}
|
||||||
*/
|
|
||||||
var width = config && config.width ? config.width : this.attrs.width;
|
|
||||||
var height = config && config.height ? config.height : this.attrs.height;
|
|
||||||
var canvas = new Kinetic.SceneCanvas(width, height);
|
|
||||||
var context = canvas.getContext();
|
|
||||||
|
|
||||||
|
|
||||||
var layers = this.children;
|
|
||||||
|
|
||||||
function drawLayer(n) {
|
function drawLayer(n) {
|
||||||
var layer = layers[n];
|
var layer = layers[n];
|
||||||
@@ -232,13 +224,14 @@
|
|||||||
* is very high quality
|
* is very high quality
|
||||||
*/
|
*/
|
||||||
toImage: function(config) {
|
toImage: function(config) {
|
||||||
this.toDataURL({
|
var cb = config.callback;
|
||||||
callback: function(dataUrl) {
|
|
||||||
Kinetic.Type._getImage(dataUrl, function(img) {
|
config.callback = function(dataUrl) {
|
||||||
config.callback(img);
|
Kinetic.Type._getImage(dataUrl, function(img) {
|
||||||
});
|
cb(img);
|
||||||
}
|
});
|
||||||
});
|
};
|
||||||
|
this.toDataURL(config);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get intersection object that contains shape and pixel data
|
* get intersection object that contains shape and pixel data
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -846,7 +846,7 @@ Test.Modules.NODE = {
|
|||||||
layer.draw();
|
layer.draw();
|
||||||
|
|
||||||
|
|
||||||
var dataUrl = layer.toDataURL();
|
//var dataUrl = layer.toDataURL();
|
||||||
|
|
||||||
// cache stage
|
// cache stage
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user