Improved import
This commit is contained in:
parent
aacde3c26e
commit
cf6ef637b7
@ -10,11 +10,9 @@ function Docs()
|
||||
|
||||
html += this.print_license();
|
||||
|
||||
var str = html;
|
||||
|
||||
dialog.showSaveDialog((fileName) => {
|
||||
if (fileName === undefined){ return; }
|
||||
fs.writeFile(fileName+".md", str, (err) => {
|
||||
fs.writeFile(fileName, html, (err) => {
|
||||
if(err){ alert("An error ocurred creating the file "+ err.message); return; }
|
||||
});
|
||||
});
|
||||
@ -72,7 +70,6 @@ function Docs()
|
||||
|
||||
for(port_name in ports){
|
||||
var port = ports[port_name];
|
||||
console.log(ports);
|
||||
html += "- `"+(port.input ? '->' : '')+""+port.name+""+(port.output ? '->' : '')+"` **("+port.value+"/"+port.max+")** "+port.docs+".\n";
|
||||
}
|
||||
return html;
|
||||
|
@ -3,8 +3,7 @@ function IO()
|
||||
this.render = function()
|
||||
{
|
||||
var fs = require('fs');
|
||||
var img = ronin.render.image();
|
||||
var data = img.replace(/^data:image\/\w+;base64,/, "");
|
||||
var data = ronin.render.to_data().replace(/^data:image\/\w+;base64,/, "");
|
||||
var buf = new Buffer(data, 'base64');
|
||||
|
||||
dialog.showSaveDialog((fileName) => {
|
||||
@ -36,11 +35,16 @@ function IO()
|
||||
base_image = new Image();
|
||||
base_image.src = event.target.result;
|
||||
|
||||
var width = base_image.naturalWidth;
|
||||
var height = base_image.naturalHeight;
|
||||
var width = parseInt(base_image.naturalWidth * 0.5);
|
||||
var height = parseInt(base_image.naturalHeight * 0.5);
|
||||
|
||||
ronin.frame.resize_to({width:width * 0.5,height:height * 0.5});
|
||||
ronin.render.context().drawImage(base_image, 0,0,width,height);
|
||||
if(height > 900){
|
||||
width *= 0.5;
|
||||
height *= 0.5;
|
||||
}
|
||||
|
||||
ronin.frame.resize_to({width:width,height:height});
|
||||
ronin.render.context().drawImage(base_image, 0,0,width * 2,height * 2);
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
@ -33,11 +33,18 @@ function Layer()
|
||||
return this.context().getImageData(x, y, width * 2, height * 2);
|
||||
}
|
||||
|
||||
this.image = function()
|
||||
this.to_data = function()
|
||||
{
|
||||
return this.el.toDataURL('image/png');
|
||||
}
|
||||
|
||||
this.to_img = function()
|
||||
{
|
||||
var img = new Image();
|
||||
img.src = this.to_data();
|
||||
return img;
|
||||
}
|
||||
|
||||
this.clear = function()
|
||||
{
|
||||
console.log("Clear")
|
||||
|
@ -2,7 +2,7 @@ function Frame()
|
||||
{
|
||||
Module.call(this,"frame");
|
||||
|
||||
this.settings = {width:200,height:200};
|
||||
this.settings = {width:400,height:400};
|
||||
|
||||
this.methods = {};
|
||||
|
||||
@ -17,20 +17,19 @@ function Frame()
|
||||
|
||||
this.methods.rescale = function(p)
|
||||
{
|
||||
var img = new Image();
|
||||
var data = ronin.render.image();
|
||||
|
||||
img.src = data;
|
||||
// Create a canvas copy
|
||||
var copy_canvas = document.createElement("canvas");
|
||||
copy_canvas.width = ronin.frame.settings.width * 2;
|
||||
copy_canvas.height = ronin.frame.settings.height * 2;
|
||||
var copy_ctx = copy_canvas.getContext("2d");
|
||||
copy_ctx.drawImage(ronin.render.to_img(), 0, 0);
|
||||
|
||||
copy_canvas.width = ronin.frame.settings.width;
|
||||
copy_canvas.height = ronin.frame.settings.height;
|
||||
copy_ctx.drawImage(img, 0, 0);
|
||||
var new_size = {width:ronin.frame.settings.width * p,height:ronin.frame.settings.height * p};
|
||||
|
||||
// ronin.render.clear();
|
||||
// ronin.frame.resize_to(p);
|
||||
ronin.render.context().drawImage(copy_ctx.canvas,0,0,ronin.frame.settings.width * 0.5,ronin.frame.settings.height * 0.5);
|
||||
// Paste
|
||||
ronin.render.clear();
|
||||
ronin.frame.resize_to(new_size);
|
||||
ronin.render.context().drawImage(copy_ctx.canvas,0,0,new_size.width * 2,new_size.height * 2);
|
||||
}
|
||||
|
||||
this.methods.crop = function(p)
|
||||
|
@ -63,5 +63,7 @@ function Ronin()
|
||||
this.render.update();
|
||||
this.grid.update();
|
||||
this.guide.update();
|
||||
|
||||
this.commander.input_el.value = "frame rescale:0.5";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user