fixed up stage toImage() translation problem

This commit is contained in:
Eric Rowell
2012-12-11 00:21:43 -08:00
parent cb8d36c393
commit 16f81f6204
3 changed files with 16 additions and 23 deletions

View File

@@ -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

View File

@@ -846,7 +846,7 @@ Test.Modules.NODE = {
layer.draw(); layer.draw();
var dataUrl = layer.toDataURL(); //var dataUrl = layer.toDataURL();
// cache stage // cache stage