Added file export
This commit is contained in:
parent
6b8e08e41f
commit
c89e199e47
@ -13,6 +13,9 @@
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const {dialog,app} = require('electron').remote;
|
||||
const fs = require('fs');
|
||||
|
||||
dotgrid = new Dotgrid(300,300,30,30,5,5, 10,"square","#000000");
|
||||
dotgrid.install();
|
||||
var keyboard = new Keyboard();
|
||||
|
@ -1,6 +1,6 @@
|
||||
body { background:#fff; padding:30px; font-family: 'input_mono_regular'; -webkit-user-select: none;-webkit-app-region: drag;}
|
||||
|
||||
#dotgrid { margin:0px auto; position:relative; border:0px solid white; background:white; overflow: hidden; cursor: none; padding:10px;}
|
||||
#dotgrid { margin:0px auto; position:relative; border:0px solid white; background:white; overflow: hidden; padding:10px;}
|
||||
#dotgrid .marker { width:2px; height:2px; background:#ddd; position:absolute; margin-top:-1px; margin-left:-1px; border-radius:4px; z-index:50;}
|
||||
#dotgrid .marker.block { background:black; }
|
||||
#dotgrid #cursor { width:8px; height:8px; margin-top:-5px; margin-left:-5px; position:absolute; z-index:25; border-radius:5px; border:1px solid black;}
|
||||
@ -19,7 +19,7 @@ pre { font-size:11px; color:#000; position:fixed; bottom:20px; display: none}
|
||||
#interface { max-width: 295px;margin:0px auto;font-size: 11px;line-height: 30px; text-transform: uppercase; margin-top:20px;}
|
||||
|
||||
.icon { width:25px; height:25px; margin-left:-5px; margin-right:0px; opacity: 0.5}
|
||||
.icon.right { float:right; opacity: 0.25}
|
||||
.icon.right { float:right;}
|
||||
.icon.inactive { opacity: 0.1 !important }
|
||||
|
||||
.icon:hover { cursor: pointer; opacity: 1 }
|
@ -110,8 +110,8 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
var pos = this.position_in_grid(e.clientX,e.clientY);
|
||||
pos = this.position_on_grid(pos[0],pos[1]);
|
||||
|
||||
this.cursor.style.left = -pos[0];
|
||||
this.cursor.style.top = pos[1];
|
||||
this.cursor.style.left = -pos[0] + 10;
|
||||
this.cursor.style.top = pos[1] + 10;
|
||||
}
|
||||
|
||||
this.mouse_up = function(e)
|
||||
@ -119,7 +119,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
var pos = this.position_in_grid(e.clientX,e.clientY);
|
||||
pos = this.position_on_grid(pos[0],pos[1]);
|
||||
|
||||
pos = [pos[0]+10,pos[1]-10]
|
||||
pos = [pos[0],pos[1]]
|
||||
|
||||
if(pos[1] > 300){ return; }
|
||||
if(pos[0] < -300){ return; }
|
||||
@ -310,10 +310,12 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
|
||||
this.export = function()
|
||||
{
|
||||
var w = window.open('about:blank');
|
||||
w.document.write("<title>Export</title>");
|
||||
w.document.write("<body></body>");
|
||||
w.document.body.innerText += this.svg_el.outerHTML;
|
||||
dialog.showSaveDialog((fileName) => {
|
||||
if (fileName === undefined){ return; }
|
||||
fs.writeFile(fileName+".svg", dotgrid.svg_el.outerHTML, (err) => {
|
||||
if(err){ alert("An error ocurred creating the file "+ err.message); return; }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.update_interface = function()
|
||||
|
@ -2,7 +2,7 @@ function Keyboard()
|
||||
{
|
||||
this.listen = function(event)
|
||||
{
|
||||
console.log(event.keyCode)
|
||||
// console.log(event.keyCode)
|
||||
switch (event.keyCode) {
|
||||
case 65 : dotgrid.draw_arc(event.shiftKey ? "1,1" : "0,1"); break;
|
||||
case 83 : dotgrid.draw_arc(event.shiftKey ? "1,0" : "0,0"); break;
|
||||
|
Loading…
Reference in New Issue
Block a user