Optimizing guide

This commit is contained in:
Devine Lu Linvega
2018-05-08 10:47:09 +12:00
parent 93496a17b8
commit 8e3d496719
6 changed files with 42 additions and 89 deletions

View File

@@ -32,7 +32,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
document.getElementById("app").appendChild(this.wrapper);
this.wrapper.appendChild(this.element);
this.element.appendChild(this.guide.el);
this.element.appendChild(this.guide.widgets);
this.wrapper.appendChild(this.render.el);
// Cursors
@@ -54,14 +53,14 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
// Vector
this.svg_el = document.createElementNS("http://www.w3.org/2000/svg", "svg");
this.svg_el.setAttribute("class","vector");
this.svg_el.setAttribute("width",this.tool.settings.width+"px");
this.svg_el.setAttribute("height",this.tool.settings.height+"px");
this.svg_el.setAttribute("width",this.tool.settings.size.width+"px");
this.svg_el.setAttribute("height",this.tool.settings.size.height+"px");
this.svg_el.setAttribute("xmlns","http://www.w3.org/2000/svg");
this.svg_el.setAttribute("baseProfile","full");
this.svg_el.setAttribute("version","1.1");
this.svg_el.style.width = this.tool.settings.width;
this.svg_el.style.height = this.tool.settings.height;
this.svg_el.style.width = this.tool.settings.size.width;
this.svg_el.style.height = this.tool.settings.size.height;
this.svg_el.style.fill = "none";
this.svg_el.style.strokeWidth = this.tool.style().thickness;
this.element.appendChild(this.svg_el);
@@ -69,13 +68,13 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.preview_el = document.createElementNS("http://www.w3.org/2000/svg", "svg");
this.preview_el.id = "preview"
this.preview_el.setAttribute("class","vector");
this.preview_el.setAttribute("width",this.tool.settings.width+"px");
this.preview_el.setAttribute("height",this.tool.settings.height+"px");
this.preview_el.setAttribute("width",this.tool.settings.size.width+"px");
this.preview_el.setAttribute("height",this.tool.settings.size.height+"px");
this.preview_el.setAttribute("xmlns","http://www.w3.org/2000/svg");
this.preview_el.setAttribute("baseProfile","full");
this.preview_el.setAttribute("version","1.1");
this.preview_el.style.width = this.tool.settings.width;
this.preview_el.style.height = this.tool.settings.height;
this.preview_el.style.width = this.tool.settings.size.width;
this.preview_el.style.height = this.tool.settings.size.height;
this.preview_el.style.strokeWidth = this.tool.style().thickness;
this.preview_el.style.strokeLinecap = this.tool.style().strokeLinecap;
this.preview_el.style.fill = this.tool.style().fill;
@@ -134,7 +133,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.controller.add("default","View","Tools",() => { dotgrid.interface.toggle(); },"U");
this.controller.add("default","View","Grid",() => { dotgrid.guide.toggle(); },"H");
this.controller.add("default","View","Control Points",() => { dotgrid.guide.toggle_widgets(); },"J");
this.controller.add("default","Mode","Keyboard",() => { dotgrid.keyboard.start(); },"CmdOrCtrl+K");
this.controller.add("default","Mode","Picker",() => { dotgrid.picker.start(); },"CmdOrCtrl+P");
@@ -428,8 +426,8 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
var win = require('electron').remote.getCurrentWindow();
win.setSize(size.width+100,size.height+100+(interface ? 10 : 0),true);
this.tool.settings.width = size.width
this.tool.settings.height = size.height
this.tool.settings.size.width = size.width
this.tool.settings.size.height = size.height
this.element.style.width = size.width+10
this.element.style.height = size.height+10
this.grid_x = size.width/15
@@ -441,11 +439,11 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.preview_el.setAttribute("width",size.width+"px");
this.preview_el.setAttribute("height",size.height+"px");
this.element.style.width = this.tool.settings.width;
this.element.style.height = this.tool.settings.height;
this.element.style.width = this.tool.settings.size.width;
this.element.style.height = this.tool.settings.size.height;
this.grid_width = this.tool.settings.width/this.grid_x;
this.grid_height = this.tool.settings.height/this.grid_y;
this.grid_width = this.tool.settings.size.width/this.grid_x;
this.grid_height = this.tool.settings.size.height/this.grid_y;
dotgrid.guide.resize(size);
this.interface.update();
@@ -463,8 +461,8 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.layer_2.setAttribute("d",paths[1]);
this.layer_3.setAttribute("d",paths[2]);
this.svg_el.style.width = this.tool.settings.width;
this.svg_el.style.height = this.tool.settings.height;
this.svg_el.style.width = this.tool.settings.size.width;
this.svg_el.style.height = this.tool.settings.size.height;
this.layer_1.style.strokeWidth = this.tool.styles[0].thickness;
this.layer_1.style.strokeLinecap = this.tool.styles[0].strokeLinecap;
@@ -568,7 +566,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.position_in_grid = function(pos)
{
return {x:(window.innerWidth/2) - (this.tool.settings.width/2) - pos.x,y:pos.y - (30+10)}
return {x:(window.innerWidth/2) - (this.tool.settings.size.width/2) - pos.x,y:pos.y - (30+10)}
}
this.position_on_grid = function(pos)
@@ -577,7 +575,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
pos.x = pos.x + 7.5
x = Math.round(pos.x/this.grid_width)*this.grid_width
y = Math.round(pos.y/this.grid_height)*this.grid_height
off = (x<-this.tool.settings.width || x>0 || y>this.tool.settings.height || y<0)
off = (x<-this.tool.settings.size.width || x>0 || y>this.tool.settings.size.height || y<0)
if(off) {
x = 50
y = -50