Various improvements to Dotgrid.
This commit is contained in:
parent
b93db5b0cd
commit
43013b2f81
30
main.js
30
main.js
@ -6,42 +6,26 @@ let win
|
||||
|
||||
app.on('ready', () =>
|
||||
{
|
||||
win = new BrowserWindow({width: 400, height: 420, minWidth: 400, minHeight: 400, maxWidth: 700, maxHeight: 720, backgroundColor:"#000", frame:false, autoHideMenuBar: true, icon: __dirname + '/icon.ico'})
|
||||
win = new BrowserWindow({width: 400, height: 420, minWidth: 400, minHeight: 400, backgroundColor:"#000", frame:false, autoHideMenuBar: true, icon: __dirname + '/icon.ico'})
|
||||
|
||||
win.loadURL(`file://${__dirname}/sources/index.html`)
|
||||
|
||||
let is_shown = true;
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
{ label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: function() { force_quit=true; app.exit(); }}
|
||||
{ label: 'File', submenu: [
|
||||
{ label: 'Inspector', accelerator: 'CmdOrCtrl+.', click: () => { win.webContents.openDevTools(); }},
|
||||
{ label: 'Guide', accelerator: 'CmdOrCtrl+,', click: () => { shell.openExternal('https://github.com/hundredrabbits/Dotgrid'); }},
|
||||
{ label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: () => { force_quit=true; app.exit(); }}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{ role: 'undo' },
|
||||
{ role: 'redo' },
|
||||
{ role: 'cut' },
|
||||
{ role: 'copy' },
|
||||
{ role: 'paste' },
|
||||
{ role: 'delete' },
|
||||
{ role: 'selectall' }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Window',
|
||||
submenu : [
|
||||
{ label: 'Window', submenu : [
|
||||
{ label: 'Hide', accelerator: 'CmdOrCtrl+H',click: () => { if(is_shown){ win.hide(); } else{ win.show(); }}},
|
||||
{ label: 'Minimize', accelerator: 'CmdOrCtrl+M',click: () => { win.minimize(); }},
|
||||
{ label: 'Fullscreen', accelerator: 'CmdOrCtrl+Enter',click: () => { win.setFullScreen(win.isFullScreen() ? false : true); }}
|
||||
]
|
||||
}
|
||||
]));
|
||||
}
|
||||
|
||||
win.on('closed', () => {
|
||||
win = null
|
||||
@ -55,8 +39,6 @@ app.on('ready', () =>
|
||||
win.on('show',function() {
|
||||
is_shown = true;
|
||||
})
|
||||
// Open the DevTools.
|
||||
// win.webContents.openDevTools()
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () =>
|
||||
|
@ -52,6 +52,8 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
document.body.appendChild(this.theme.el);
|
||||
|
||||
document.getElementById("app").appendChild(this.wrapper);
|
||||
this.wrapper.appendChild(this.element);
|
||||
this.element.appendChild(this.guide.el);
|
||||
@ -245,22 +247,22 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
this.preview = function(operation)
|
||||
{
|
||||
if(from && to && operation == "line"){
|
||||
var d = new Path_Line(from.mirror(),to.mirror(),end.mirror()).to_segment();
|
||||
var d = new Path_Line(from.mirror(),to.mirror(),end ? end.mirror() : null).to_segment();
|
||||
this.preview_el.innerHTML = "<path d='"+d+"'></path>"
|
||||
return;
|
||||
}
|
||||
else if(from && to && operation == "arc_c"){
|
||||
var d = new Path_Arc(from.mirror(),to.mirror(),"0,1",end.mirror()).to_segment();
|
||||
var d = new Path_Arc(from.mirror(),to.mirror(),"0,1",end ? end.mirror() : null).to_segment();
|
||||
this.preview_el.innerHTML = "<path d='"+d+"'></path>"
|
||||
return;
|
||||
}
|
||||
else if(from && to && operation == "arc_r"){
|
||||
var d = new Path_Arc(from.mirror(),to.mirror(),"0,0",end.mirror()).to_segment();
|
||||
var d = new Path_Arc(from.mirror(),to.mirror(),"0,0",end ? end.mirror() : null).to_segment();
|
||||
this.preview_el.innerHTML = "<path d='"+d+"'></path>"
|
||||
return;
|
||||
}
|
||||
else if(from && to && operation == "bezier"){
|
||||
var d = new Path_Bezier(from.mirror(),to.mirror(),end.mirror()).to_segment();
|
||||
var d = new Path_Bezier(from.mirror(),to.mirror(),end ? end.mirror() : null).to_segment();
|
||||
this.preview_el.innerHTML = "<path d='"+d+"'></path>"
|
||||
return;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ function Guide()
|
||||
ctx.lineTo((to.x * -2)+20,(to.y * 2)+20);
|
||||
ctx.lineCap="round";
|
||||
ctx.lineWidth = 5;
|
||||
ctx.strokeStyle = dotgrid.theme.active.f_high;
|
||||
ctx.strokeStyle = dotgrid.theme.active.f_inv;
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ function Path_Bezier(from,to,end)
|
||||
this.to_segment = function(prev)
|
||||
{
|
||||
var html = ""
|
||||
if(!this.end){ return ""; }
|
||||
|
||||
if(!prev || (!prev.to && !prev.end)){
|
||||
html += "M"+this.from.scale(dotgrid.scale)+" ";
|
||||
|
@ -3,20 +3,17 @@ function Theme()
|
||||
this.el = document.createElement("style");
|
||||
this.active = null;
|
||||
|
||||
this.collection = {};
|
||||
this.collection.blanc = { background:"#eee",f_high:"#111",f_med:"#999",f_low:"#ddd",f_inv:"#fff",f_inv:"#000",b_high:"#000",b_med:"#999",b_low:"#ddd",b_inv:"#999",b_inv:"#72dec2" };
|
||||
this.default = { background: "#222", f_high: "#fff", f_med: "#777", f_low: "#444", f_inv: "#affec7", b_high: "#000", b_med: "#affec7", b_low: "#000", b_inv: "#affec7" }
|
||||
|
||||
this.start = function()
|
||||
{
|
||||
document.body.appendChild(this.el);
|
||||
|
||||
if(localStorage.theme && is_json(localStorage.theme)){
|
||||
console.log("Theme","Found in localStorage")
|
||||
this.install(JSON.parse(localStorage.theme));
|
||||
}
|
||||
else{
|
||||
console.log("Theme","Creating new")
|
||||
this.install(this.collection.blanc);
|
||||
this.install(this.default);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,9 +28,6 @@ function Theme()
|
||||
if(is_json(theme_str)){
|
||||
this.install(JSON.parse(theme_str));
|
||||
}
|
||||
else if(this.collection[theme_str]){
|
||||
this.install(this.collection[theme_str]);
|
||||
}
|
||||
console.log("Theme","Loaded");
|
||||
}
|
||||
|
||||
@ -70,7 +64,7 @@ function Theme()
|
||||
this.reset = function()
|
||||
{
|
||||
console.log("Theme","reset");
|
||||
this.install(this.collection.blanc);
|
||||
this.install(this.default);
|
||||
}
|
||||
|
||||
function is_json(text)
|
||||
|
Loading…
Reference in New Issue
Block a user