Image render

This commit is contained in:
Devine Lu Linvega 2017-09-27 15:22:07 +13:00
parent 1fd7202893
commit 0b4142b1ad
6 changed files with 29 additions and 10 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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();

View File

@ -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();

View File

@ -35,7 +35,7 @@ function Layer()
this.image = function()
{
return this.element.toDataURL('image/png');
return this.el.toDataURL('image/png');
}
this.clear = function()

View File

@ -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);