From 0e06026b1085e633229f11b8c6264f39b2b0f662 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega <aliceffekt@gmail.com> Date: Wed, 18 Jan 2017 09:45:46 -0700 Subject: [PATCH] Moved merge to Save --- sources/scripts/modules/file.save.js | 17 +++++++++++++++-- sources/scripts/modules/surface.js | 16 ---------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/sources/scripts/modules/file.save.js b/sources/scripts/modules/file.save.js index 4613718..800b8d0 100644 --- a/sources/scripts/modules/file.save.js +++ b/sources/scripts/modules/file.save.js @@ -20,13 +20,26 @@ function FileSave(rune) var d = null; if(cmd.variable("format") && cmd.variable("format").value == "jpg"){ - var d = ronin.surface.active_layer.element.toDataURL('image/jpeg'); + var d = this.merge().element.toDataURL('image/jpeg'); } else{ - var d = ronin.surface.active_layer.element.toDataURL('image/png'); + var d = this.merge().element.toDataURL('image/png'); } var w = window.open('about:blank','image from canvas'); w.document.write("<title>Untitled</title><body><img src='"+d+"' width='"+ronin.surface.size.width+"px' height='"+ronin.surface.size.height+"px'/></body>"); + this.layer.clear(); + } + + this.merge = function() + { + var a = []; + Object.keys(ronin.surface.layers).forEach(function (key) { + a.push(ronin.surface.layers[key]); + }); + for (i = 0; i < a.length; i++) { + this.layer.context().drawImage(a[i].context().canvas,0,0,ronin.surface.size.width,ronin.surface.size.height); + } + return this.layer; } } \ No newline at end of file diff --git a/sources/scripts/modules/surface.js b/sources/scripts/modules/surface.js index e5d3334..ad01f5c 100644 --- a/sources/scripts/modules/surface.js +++ b/sources/scripts/modules/surface.js @@ -131,22 +131,6 @@ function Surface(rune) { return this.active_layer.context(); } - - this.merge = function() - { - // this.render_layer = this.layers["render"]; - - // var a = []; - // Object.keys(ronin.surface.layers).forEach(function (key) { - // if(key != "render"){ - // a.push(ronin.surface.layers[key]); - // } - // }); - // for (i = a.length; i > 0 ; i--) { - // ronin.surface.render_layer.context().drawImage(a[i-1].context().canvas,0,0,this.size.width,this.size.height); - // } - return this.context(); - } // Cursor