diff --git a/README.md b/README.md index d4dd791..2e40f46 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ Ronin is a simple open-source graphic design tool. ### Methods ### Ports -- `speed->` *0/50* The cursor speed. -- `distance->` *0/9999* The cursor distance. -- `->red->` *0/255* The brush color value(red). -- `->green->` *0/255* The brush color value(green). -- `->blue->` *0/255* The brush color value(blue). +- `speed->` **(0/50)** The cursor speed. +- `distance->` **(0/9999)** The cursor distance. +- `->red->` **(0/255)** The brush color value(red). +- `->green->` **(0/255)** The brush color value(green). +- `->blue->` **(0/255)** The brush color value(blue). ## eraser ### Settings @@ -46,8 +46,8 @@ Ronin is a simple open-source graphic design tool. - `stroke:`, no details. ### Ports -- `step->` *0/100* The tween line index.. -- `->thickness->` *4/100* The tween line thickness.. +- `step->` **(0/100)** The tween line index.. +- `->thickness->` **(4/100)** The tween line thickness.. ## License diff --git a/sources/scripts/docs.js b/sources/scripts/docs.js index db124c1..65d496c 100644 --- a/sources/scripts/docs.js +++ b/sources/scripts/docs.js @@ -14,7 +14,7 @@ function Docs() dialog.showSaveDialog((fileName) => { if (fileName === undefined){ return; } - fs.writeFile("README.md", str, (err) => { + fs.writeFile(fileName+".md", str, (err) => { if(err){ alert("An error ocurred creating the file "+ err.message); return; } }); }); @@ -73,7 +73,7 @@ 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"; + html += "- `"+(port.input ? '->' : '')+""+port.name+""+(port.output ? '->' : '')+"` **("+port.value+"/"+port.max+")** "+port.docs+".\n"; } return html; } diff --git a/sources/scripts/io.js b/sources/scripts/io.js index 41af878..2275810 100644 --- a/sources/scripts/io.js +++ b/sources/scripts/io.js @@ -1,5 +1,18 @@ function IO() { + this.render = function() + { + var fs = require('fs'); + var img = ronin.render.image(); + var data = img.replace(/^data:image\/\w+;base64,/, ""); + var buf = new Buffer(data, 'base64'); + + dialog.showSaveDialog((fileName) => { + if (fileName === undefined){ return; } + fs.writeFile(fileName+'.png', buf); + }); + } + this.drag_over = function(e) { e.stopPropagation(); diff --git a/sources/scripts/keyboard.js b/sources/scripts/keyboard.js index df530d5..a2458d0 100644 --- a/sources/scripts/keyboard.js +++ b/sources/scripts/keyboard.js @@ -33,6 +33,11 @@ function Keyboard() ronin.render.clear(); } + if(e.key == "r" && (e.ctrlKey || e.metaKey)){ + e.preventDefault(); + ronin.io.render(); + } + if(e.key == "H" && (e.ctrlKey || e.metaKey) && e.shiftKey){ e.preventDefault(); ronin.docs.export(); diff --git a/sources/scripts/layer.js b/sources/scripts/layer.js index bd2f399..c700e79 100644 --- a/sources/scripts/layer.js +++ b/sources/scripts/layer.js @@ -35,7 +35,7 @@ function Layer() this.image = function() { - return this.element.toDataURL('image/png'); + return this.el.toDataURL('image/png'); } this.clear = function() diff --git a/sources/scripts/port.js b/sources/scripts/port.js index 7c63a2f..b7c8287 100644 --- a/sources/scripts/port.js +++ b/sources/scripts/port.js @@ -14,6 +14,7 @@ function Port(host,name,input,output,value,max,docs) this.value = value; var target = this.host.routes[this.name]; + if(!this.output){ return; } if(!target){ console.log("No output for",this.name); return; } this.host.ports[target].write(this.value);