Implemented export format
This commit is contained in:
parent
563fe93571
commit
5d878cfc21
@ -43,17 +43,17 @@ function Keyboard()
|
|||||||
|
|
||||||
if(e.key == "o" && (e.ctrlKey || e.metaKey)){
|
if(e.key == "o" && (e.ctrlKey || e.metaKey)){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ronin.io.methods.import();
|
ronin.io.methods.load.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.key == "s" && (e.ctrlKey || e.metaKey)){
|
if(e.key == "s" && (e.ctrlKey || e.metaKey)){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ronin.io.save();
|
ronin.io.methods.save.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.key == "r" && (e.ctrlKey || e.metaKey)){
|
if(e.key == "r" && (e.ctrlKey || e.metaKey)){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ronin.io.render();
|
ronin.io.methods.save.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.key == "H" && (e.ctrlKey || e.metaKey) && e.shiftKey){
|
if(e.key == "H" && (e.ctrlKey || e.metaKey) && e.shiftKey){
|
||||||
|
@ -5,7 +5,6 @@ function IO()
|
|||||||
this.image = null;
|
this.image = null;
|
||||||
|
|
||||||
this.methods.load = new Method("load","browser","Press enter to open the file browser.",function(q){
|
this.methods.load = new Method("load","browser","Press enter to open the file browser.",function(q){
|
||||||
|
|
||||||
var filepath = q ? [q] : dialog.showOpenDialog({properties: ['openFile']});
|
var filepath = q ? [q] : dialog.showOpenDialog({properties: ['openFile']});
|
||||||
|
|
||||||
if(!filepath){ console.log("Nothing to load"); return; }
|
if(!filepath){ console.log("Nothing to load"); return; }
|
||||||
@ -31,14 +30,15 @@ function IO()
|
|||||||
ronin.preview.clear();
|
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 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');
|
var buf = new Buffer(data, 'base64');
|
||||||
|
|
||||||
dialog.showSaveDialog((fileName) => {
|
dialog.showSaveDialog((fileName) => {
|
||||||
if (fileName === undefined){ return; }
|
if (fileName === undefined){ return; }
|
||||||
fs.writeFile(fileName+'.jpg', buf);
|
fs.writeFile(fileName+'.'+ext, buf);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,7 +2,18 @@ function Path()
|
|||||||
{
|
{
|
||||||
Module.call(this,"path","Trace lines and to draw shapes.");
|
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){
|
this.methods.stroke = new Method("stroke","x,y&","",function(q){
|
||||||
ronin.preview.clear();
|
ronin.preview.clear();
|
||||||
@ -12,9 +23,9 @@ function Path()
|
|||||||
var ctx = ronin.render.context();
|
var ctx = ronin.render.context();
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.lineCap = "butt";
|
ctx.lineCap = r.path.settings.cap;
|
||||||
ctx.lineWidth = 30;
|
ctx.lineWidth = r.path.settings.thickness;
|
||||||
ctx.strokeStyle = "black";
|
ctx.strokeStyle = r.path.settings.color;
|
||||||
ctx.stroke(new Path2D(path));
|
ctx.stroke(new Path2D(path));
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
});
|
});
|
||||||
@ -27,9 +38,9 @@ function Path()
|
|||||||
var ctx = ronin.render.context();
|
var ctx = ronin.render.context();
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.lineCap = "butt";
|
ctx.lineCap = r.path.settings.cap;
|
||||||
ctx.lineWidth = 30;
|
ctx.lineWidth = r.path.settings.thickness;
|
||||||
ctx.fillStyle = "black";
|
ctx.strokeStyle = r.path.settings.color;
|
||||||
ctx.fill(new Path2D(path));
|
ctx.fill(new Path2D(path));
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user