Re-implemented io.load

This commit is contained in:
Devine Lu Linvega 2018-01-20 14:33:15 +13:00
parent 7693356826
commit b5972beb1a
2 changed files with 10 additions and 9 deletions

View File

@ -43,7 +43,6 @@ function IO()
ronin.io.draw_image(ronin.cursor.target.context(),ronin.io.image,ronin.commander.query().methods.draw); ronin.io.draw_image(ronin.cursor.target.context(),ronin.io.image,ronin.commander.query().methods.draw);
ronin.io.image = null; ronin.io.image = null;
ronin.preview.clear();
}); });
this.methods.save = new Method("save","jpg/png","Export canvas.",function(q){ this.methods.save = new Method("save","jpg/png","Export canvas.",function(q){
@ -58,14 +57,14 @@ function IO()
}); });
}); });
this.preview = function(q) // this.preview = function(q)
{ // {
ronin.preview.clear(); // ronin.preview.clear();
if(ronin.commander.query().methods.draw && this.image){ // if(ronin.commander.query().methods.draw && this.image){
this.draw_image(ronin.preview.context(),this.image,ronin.commander.query().methods.draw); // this.draw_image(ronin.preview.context(),this.image,ronin.commander.query().methods.draw);
} // }
} // }
this.render = function() this.render = function()
{ {
@ -77,7 +76,7 @@ function IO()
return export_layer; return export_layer;
} }
this.draw_image = function(ctx = ronin.preview.context(),img,params) this.draw_image = function(ctx,img,params)
{ {
var width = parseInt(img.naturalWidth * 0.5); var width = parseInt(img.naturalWidth * 0.5);
var height = parseInt(img.naturalHeight * 0.5); var height = parseInt(img.naturalHeight * 0.5);

View File

@ -76,6 +76,8 @@ function Ronin()
this.controller.add("default","File","Open",() => { ronin.open(); },"CmdOrCtrl+O"); this.controller.add("default","File","Open",() => { ronin.open(); },"CmdOrCtrl+O");
this.controller.add("default","File","Save",() => { ronin.save(); },"CmdOrCtrl+S"); this.controller.add("default","File","Save",() => { ronin.save(); },"CmdOrCtrl+S");
this.controller.add("default","I/O","Import Image",() => { ronin.io.methods.load.run(); },"CmdOrCtrl+I");
this.controller.add("default","Layers","Above Layer",() => { ronin.cursor.select_layer(ronin.layers.above); },"c"); this.controller.add("default","Layers","Above Layer",() => { ronin.cursor.select_layer(ronin.layers.above); },"c");
this.controller.add("default","Layers","Below Layer",() => { ronin.cursor.select_layer(ronin.layers.below); },"z"); this.controller.add("default","Layers","Below Layer",() => { ronin.cursor.select_layer(ronin.layers.below); },"z");
this.controller.add("default","Layers","Toggle Layer",() => { ronin.cursor.swap_layer(); },"x"); this.controller.add("default","Layers","Toggle Layer",() => { ronin.cursor.swap_layer(); },"x");