diff --git a/sources/scripts/modules/frame.js b/sources/scripts/modules/frame.js index e56a4a7..5af4bf0 100644 --- a/sources/scripts/modules/frame.js +++ b/sources/scripts/modules/frame.js @@ -38,7 +38,7 @@ function Frame() }); this.methods.fill = new Method("fill","#f00","Fill entire canvas with color",function(q){ - ronin.render.fill(q); + ronin.render.fill(q ? q : ronin.brush.settings.color); }); this.methods.inspect = new Method("inspect","","View canvas details",function(q){ diff --git a/sources/scripts/modules/io.js b/sources/scripts/modules/io.js index 9246aef..3529b28 100644 --- a/sources/scripts/modules/io.js +++ b/sources/scripts/modules/io.js @@ -4,12 +4,28 @@ function IO() this.image = null; - this.methods.load = new Method("load","browser","Press enter to open the file browser.",function(q){ + this.methods.open = new Method("open","browser","Press enter to open the file browser.",function(q){ var filepath = q ? [q] : dialog.showOpenDialog({properties: ['openFile']}); if(!filepath){ console.log("Nothing to load"); return; } - console.log("Loaded",filepath) + fs.readFile(filepath[0], 'utf-8', (err, data) => { + if(err){ alert("An error ocurred reading the file :" + err.message); return; } + var img = new Image(); + img.src = filepath[0]; + img.onload = function() { + var width = parseInt(img.naturalWidth * 0.5); + var height = parseInt(img.naturalHeight * 0.5); + ronin.frame.resize_to({width:width,height:height}); + ronin.io.draw_image(ronin.render.context(),img,{x:0,y:0,width:width,height:height}); + } + }); + }) + + this.methods.load = new Method("load","browser","Press enter to open the file browser.",function(q){ + var filepath = q ? [q] : dialog.showOpenDialog({properties: ['openFile']}); + + if(!filepath){ console.log("Nothing to load"); return; } fs.readFile(filepath[0], 'utf-8', (err, data) => { if(err){ alert("An error ocurred reading the file :" + err.message); return; }