diff --git a/sources/scripts/core/keyboard.js b/sources/scripts/core/keyboard.js index b03c0b1..ac5f658 100644 --- a/sources/scripts/core/keyboard.js +++ b/sources/scripts/core/keyboard.js @@ -43,17 +43,17 @@ function Keyboard() if(e.key == "o" && (e.ctrlKey || e.metaKey)){ e.preventDefault(); - ronin.io.methods.import(); + ronin.io.methods.load.run(); } if(e.key == "s" && (e.ctrlKey || e.metaKey)){ e.preventDefault(); - ronin.io.save(); + ronin.io.methods.save.run(); } if(e.key == "r" && (e.ctrlKey || e.metaKey)){ e.preventDefault(); - ronin.io.render(); + ronin.io.methods.save.run(); } if(e.key == "H" && (e.ctrlKey || e.metaKey) && e.shiftKey){ diff --git a/sources/scripts/modules/io.js b/sources/scripts/modules/io.js index cd3c8db..8e7d2bd 100644 --- a/sources/scripts/modules/io.js +++ b/sources/scripts/modules/io.js @@ -5,7 +5,6 @@ function IO() this.image = null; 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; } @@ -31,14 +30,15 @@ function IO() ronin.preview.clear(); }); - this.methods.save = new Method("save","name","Export canvas.",function(q){ + this.methods.save = new Method("save","jpg/png","Export canvas.",function(q){ + var ext = q ? q : "jpg"; var fs = require('fs'); - var data = ronin.render.to_base64('jpg').replace(/^data:image\/\w+;base64,/, ""); + var data = ronin.render.to_base64(ext).replace(/^data:image\/\w+;base64,/, ""); var buf = new Buffer(data, 'base64'); dialog.showSaveDialog((fileName) => { if (fileName === undefined){ return; } - fs.writeFile(fileName+'.jpg', buf); + fs.writeFile(fileName+'.'+ext, buf); }); }); diff --git a/sources/scripts/modules/path.js b/sources/scripts/modules/path.js index 3f5af1a..1de4924 100644 --- a/sources/scripts/modules/path.js +++ b/sources/scripts/modules/path.js @@ -2,8 +2,19 @@ function Path() { Module.call(this,"path","Trace lines and to draw shapes."); - this.settings = {thickness:30,color:"black",cap:"square"}; + this.settings = {thickness:4,color:"white",cap:"square"}; + this.methods.svg = new Method("svg","M0,0 L100,100","",function(q){ + var path = ronin.commander.query().raw.replace("svg:","").trim(); + var ctx = ronin.render.context(); + ctx.beginPath(); + ctx.lineCap = ronin.path.settings.cap; + ctx.lineWidth = ronin.path.settings.thickness; + ctx.strokeStyle = ronin.path.settings.color; + ctx.stroke(new Path2D(path)); + ctx.closePath(); + }); + this.methods.stroke = new Method("stroke","x,y&","",function(q){ ronin.preview.clear(); @@ -12,9 +23,9 @@ function Path() var ctx = ronin.render.context(); ctx.beginPath(); - ctx.lineCap = "butt"; - ctx.lineWidth = 30; - ctx.strokeStyle = "black"; + ctx.lineCap = r.path.settings.cap; + ctx.lineWidth = r.path.settings.thickness; + ctx.strokeStyle = r.path.settings.color; ctx.stroke(new Path2D(path)); ctx.closePath(); }); @@ -27,9 +38,9 @@ function Path() var ctx = ronin.render.context(); ctx.beginPath(); - ctx.lineCap = "butt"; - ctx.lineWidth = 30; - ctx.fillStyle = "black"; + ctx.lineCap = r.path.settings.cap; + ctx.lineWidth = r.path.settings.thickness; + ctx.strokeStyle = r.path.settings.color; ctx.fill(new Path2D(path)); ctx.closePath(); });