diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index 57759c1..47d1b4f 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -99,7 +99,7 @@ function Cursor() this.pos_snap = function(pos) { - var grid = dotgrid.tool.settings.size.width/dotgrid.grid_x; + let grid = dotgrid.tool.settings.size.width/dotgrid.grid_x; return { x:clamp(step(pos.x,grid),grid,dotgrid.tool.settings.size.width), y:clamp(step(pos.y,grid),grid,dotgrid.tool.settings.size.height+grid) diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js index f56278d..a901fe6 100644 --- a/desktop/sources/scripts/dotgrid.js +++ b/desktop/sources/scripts/dotgrid.js @@ -48,7 +48,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.open = function() { - var paths = dialog.showOpenDialog({properties: ['openFile'],filters:[{name:"Dotgrid Image",extensions:["dot","grid"]}]}); + if(!dialog){ return; } + + let paths = dialog.showOpenDialog({properties: ['openFile'],filters:[{name:"Dotgrid Image",extensions:["dot","grid"]}]}); if(!paths){ console.log("Nothing to load"); return; } @@ -76,7 +78,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.save_web = function(content) { console.info("Web Save"); - var win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`); + let win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`); win.document.body.innerHTML = `

To save: Copy this into a .grid file.
To load: Drag the .grid onto the browser window.

${content}
`; } @@ -118,7 +120,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.export_web = function(content) { console.info("Web Export"); - var win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`); + let win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`); win.document.body.innerHTML = `${dotgrid.renderer.to_svg()}`; } @@ -132,7 +134,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.tool.settings.size.height = size.height try{ - var win = require('electron').remote.getCurrentWindow(); + let win = require('electron').remote.getCurrentWindow(); win.setSize((size.width+100)*scale,(size.height+100+(interface ? 10 : 0))*scale,true); } catch(err){ @@ -182,7 +184,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.refresh = function() { - var size = {width:step(window.innerWidth-90,15),height:step(window.innerHeight-120,15)} + let size = {width:step(window.innerWidth-90,15),height:step(window.innerHeight-120,15)} dotgrid.tool.settings.size.width = size.width dotgrid.tool.settings.size.height = size.height @@ -205,11 +207,11 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) e.preventDefault(); e.stopPropagation(); - var file = e.dataTransfer.files[0]; + let file = e.dataTransfer.files[0]; if(!file.path || file.path.indexOf(".dot") < 0 && file.path.indexOf(".grid") < 0){ console.log("Dotgrid","Not a dot file"); return; } - var reader = new FileReader(); + let reader = new FileReader(); reader.onload = function(e){ dotgrid.tool.replace(JSON.parse(e.target.result.toString().trim())); dotgrid.guide.refresh(); @@ -250,7 +252,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.paste = function(e) { if(e.target !== this.picker.el){ - var data = e.clipboardData.getData("text/source"); + let data = e.clipboardData.getData("text/source"); if (is_json(data)) { data = JSON.parse(data.trim()); dotgrid.tool.import(data); diff --git a/desktop/sources/scripts/generator.js b/desktop/sources/scripts/generator.js index fdcf064..71c8f52 100644 --- a/desktop/sources/scripts/generator.js +++ b/desktop/sources/scripts/generator.js @@ -5,11 +5,11 @@ function Generator(layer,style) function operate(layer,offset,scale,mirror = 0,angle = 0) { - var l = copy(layer) + let l = copy(layer) - for(k1 in l){ - var seg = l[k1]; - for(k2 in seg.vertices){ + for(let k1 in l){ + let seg = l[k1]; + for(let k2 in seg.vertices){ if(mirror == 1){ seg.vertices[k2].x = (dotgrid.tool.settings.size.width) - seg.vertices[k2].x + 15 } if(mirror == 2){ seg.vertices[k2].y = (dotgrid.tool.settings.size.height) - seg.vertices[k2].y + 30 } @@ -18,7 +18,7 @@ function Generator(layer,style) seg.vertices[k2].y += offset.y // Rotate - var center = {x:(dotgrid.tool.settings.size.width/2)+offset.x+(7.5),y:(dotgrid.tool.settings.size.height/2)+offset.y+30} + let center = {x:(dotgrid.tool.settings.size.width/2)+offset.x+(7.5),y:(dotgrid.tool.settings.size.height/2)+offset.y+30} seg.vertices[k2] = rotate_point(seg.vertices[k2],center,angle) // Scale @@ -31,17 +31,17 @@ function Generator(layer,style) this.render = function(prev,segment,mirror = 0) { - var type = segment.type; - var vertices = segment.vertices; - var html = ''; - var skip = 0; + let type = segment.type; + let vertices = segment.vertices; + let html = ''; + let skip = 0; - for(id in vertices){ + for(let id in vertices){ if(skip > 0){ skip -= 1; continue; } - var vertex = vertices[id] - var next = vertices[parseInt(id)+1] - var after_next = vertices[parseInt(id)+2] + let vertex = vertices[id] + let next = vertices[parseInt(id)+1] + let after_next = vertices[parseInt(id)+2] if(id == 0 && !prev || id == 0 && prev && (prev.x != vertex.x || prev.y != vertex.y)){ html += `M${vertex.x},${vertex.y} ` @@ -51,11 +51,11 @@ function Generator(layer,style) html += `L${vertex.x},${vertex.y} `; } else if(type == "arc_c"){ - var clock = mirror > 0 ? '0,0' : '0,1' + let clock = mirror > 0 ? '0,0' : '0,1' html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : ''; } else if(type == "arc_r"){ - var clock = mirror > 0 ? '0,1' : '0,0' + let clock = mirror > 0 ? '0,1' : '0,0' html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : ''; } else if(type == "bezier"){ @@ -76,10 +76,10 @@ function Generator(layer,style) this.convert = function(layer,mirror,angle) { - var s = "" - var prev = null - for(id in layer){ - var seg = layer[id]; + let s = "" + let prev = null + for(let id in layer){ + let seg = layer[id]; s += `${this.render(prev,seg,mirror)}` prev = seg.vertices ? seg.vertices[seg.vertices.length-1] : null } @@ -89,7 +89,7 @@ function Generator(layer,style) this.toString = function(offset = {x:0,y:0}, scale = 1, mirror = this.style && this.style.mirror_style ? this.style.mirror_style : 0) { - var s = this.convert(operate(this.layer,offset,scale)) + let s = this.convert(operate(this.layer,offset,scale)) if(mirror == 1 || mirror == 2){ s += this.convert(operate(this.layer,offset,scale,mirror),mirror) diff --git a/desktop/sources/scripts/guide.js b/desktop/sources/scripts/guide.js index ea88690..d0a12be 100644 --- a/desktop/sources/scripts/guide.js +++ b/desktop/sources/scripts/guide.js @@ -48,7 +48,7 @@ function Guide() this.resize = function(size) { - var offset = 15 + let offset = 15 this.el.width = (size.width+offset)*this.scale; this.el.height = (size.height+(offset*2))*this.scale; this.el.style.width = (size.width+offset)+"px"; @@ -61,10 +61,10 @@ function Guide() { if(!this.show_extras){ return; } - for(segment_id in dotgrid.tool.layer()){ - var segment = dotgrid.tool.layer()[segment_id]; - for(vertex_id in segment.vertices){ - var vertex = segment.vertices[vertex_id]; + for(let segment_id in dotgrid.tool.layer()){ + let segment = dotgrid.tool.layer()[segment_id]; + for(let vertex_id in segment.vertices){ + let vertex = segment.vertices[vertex_id]; this.draw_handle(vertex); } } @@ -72,7 +72,7 @@ function Guide() this.draw_vertices = function() { - for(id in dotgrid.tool.vertices){ + for(let id in dotgrid.tool.vertices){ this.draw_vertex(dotgrid.tool.vertices[id]); } } @@ -81,14 +81,14 @@ function Guide() { if(!this.show_extras){ return; } - var cursor = {x:parseInt(dotgrid.cursor.pos.x/dotgrid.grid_width),y:parseInt(dotgrid.cursor.pos.y/dotgrid.grid_width)} + let cursor = {x:parseInt(dotgrid.cursor.pos.x/dotgrid.grid_width),y:parseInt(dotgrid.cursor.pos.y/dotgrid.grid_width)} - for (var x = dotgrid.grid_x-1; x >= 0; x--) { - for (var y = dotgrid.grid_y; y >= 0; y--) { - var is_step = x % dotgrid.block_x == 0 && y % dotgrid.block_y == 0; + for (let x = dotgrid.grid_x-1; x >= 0; x--) { + for (let y = dotgrid.grid_y; y >= 0; y--) { + let is_step = x % dotgrid.block_x == 0 && y % dotgrid.block_y == 0; // Color - var color = is_step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low; + let color = is_step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low; if((y == 0 || y == dotgrid.grid_y) && cursor.x == x+1){ color = dotgrid.theme.active.f_high; } else if((x == 0 || x == dotgrid.grid_x-1) && cursor.y == y+1){ color = dotgrid.theme.active.f_high; } else if(cursor.x == x+1 && cursor.y == y+1){ color = dotgrid.theme.active.f_high; } @@ -103,7 +103,7 @@ function Guide() this.draw_marker = function(pos,radius = 1,color) { - var ctx = this.el.getContext('2d'); + let ctx = this.el.getContext('2d'); ctx.beginPath(); ctx.lineWidth = 2; ctx.arc(pos.x * this.scale, pos.y * this.scale, radius, 0, 2 * Math.PI, false); @@ -114,7 +114,7 @@ function Guide() this.draw_vertex = function(pos, radius = 5) { - var ctx = this.el.getContext('2d'); + let ctx = this.el.getContext('2d'); ctx.beginPath(); ctx.lineWidth = 2; ctx.arc((pos.x * this.scale), (pos.y * this.scale), radius, 0, 2 * Math.PI, false); @@ -125,7 +125,7 @@ function Guide() this.draw_handle = function(pos, radius = 6) { - var ctx = this.el.getContext('2d'); + let ctx = this.el.getContext('2d'); ctx.beginPath(); ctx.lineWidth = 3; @@ -152,8 +152,8 @@ function Guide() this.draw_path = function(path,style) { - var ctx = this.el.getContext('2d'); - var p = new Path2D(path); + let ctx = this.el.getContext('2d'); + let p = new Path2D(path); ctx.strokeStyle = style.color; ctx.lineWidth = style.thickness * this.scale; @@ -175,7 +175,7 @@ function Guide() { if(!dotgrid.cursor.translation){ return; } - var ctx = this.el.getContext('2d'); + let ctx = this.el.getContext('2d'); ctx.beginPath(); ctx.moveTo((dotgrid.cursor.translation.from.x * this.scale),(dotgrid.cursor.translation.from.y * this.scale)); @@ -193,7 +193,7 @@ function Guide() this.draw_cursor = function(pos = dotgrid.cursor.pos,radius = dotgrid.tool.style().thickness-1) { - var ctx = this.el.getContext('2d'); + let ctx = this.el.getContext('2d'); ctx.beginPath(); ctx.lineWidth = 3; @@ -214,14 +214,14 @@ function Guide() this.draw_preview = function() { - var ctx = this.el.getContext('2d'); - var operation = dotgrid.cursor.operation && dotgrid.cursor.operation.cast ? dotgrid.cursor.operation.cast : null + let ctx = this.el.getContext('2d'); + let operation = dotgrid.cursor.operation && dotgrid.cursor.operation.cast ? dotgrid.cursor.operation.cast : null if(!dotgrid.tool.can_cast(operation)){ return; } if(operation == "close"){ return; } - var path = new Generator([{vertices:dotgrid.tool.vertices,type:operation}]).toString({x:0,y:0},2) - var style = { + let path = new Generator([{vertices:dotgrid.tool.vertices,type:operation}]).toString({x:0,y:0},2) + let style = { color:dotgrid.theme.active.f_med, thickness:2, strokeLinecap:"round", diff --git a/desktop/sources/scripts/interface.js b/desktop/sources/scripts/interface.js index 7ab91b1..8884049 100644 --- a/desktop/sources/scripts/interface.js +++ b/desktop/sources/scripts/interface.js @@ -14,8 +14,8 @@ function Interface() document.getElementById("app").appendChild(this.el); this.el.appendChild(dotgrid.picker.el); - var html = "" - var options = { + let html = "" + let options = { cast:{ line: { key:"A",icon:"M60,60 L240,240" }, arc_c: { key:"S",icon:"M60,60 A180,180 0 0,1 240,240" }, @@ -42,10 +42,10 @@ function Interface() } } - for(type in options){ - var tools = options[type]; - for(name in tools){ - var tool = tools[name]; + for(let type in options){ + let tools = options[type]; + for(let name in tools){ + let tool = tools[name]; html += ` 2){ multi_vertices = true; break; } + for(let i in segments){ + if(segments[i].vertices.length > 2){ multi_vertices = true; break; } } document.getElementById("option_line").className.baseVal = !dotgrid.tool.can_cast("line") ? "icon inactive" : "icon"; diff --git a/desktop/sources/scripts/lib/controller.js b/desktop/sources/scripts/lib/controller.js index 89dd9ca..e2ee467 100644 --- a/desktop/sources/scripts/lib/controller.js +++ b/desktop/sources/scripts/lib/controller.js @@ -32,12 +32,12 @@ function Controller() this.format = function() { - var f = []; - var m = this.menu[this.mode]; - for(cat in m){ - var submenu = []; - for(name in m[cat]){ - var option = m[cat][name]; + let f = []; + let m = this.menu[this.mode]; + for(let cat in m){ + let submenu = []; + for(let name in m[cat]){ + let option = m[cat][name]; if(option.role){ submenu.push({role:option.role}) } @@ -58,8 +58,8 @@ function Controller() this.docs = function() { console.log("Generating docs.."); - var svg = this.generate_svg(this.format()) - var txt = this.documentation(this.format()); + let svg = this.generate_svg(this.format()) + let txt = this.documentation(this.format()); dialog.showSaveDialog((fileName) => { if (fileName === undefined){ return; } fileName = fileName.substr(-4,4) != ".svg" ? fileName+".svg" : fileName; @@ -70,11 +70,11 @@ function Controller() this.generate_svg = function(m) { - var svg_html = ""; + let svg_html = ""; - for(id in this.layout){ - var key = this.layout[id]; - var acc = this.accelerator_for_key(key.name,m); + for(let id in this.layout){ + let key = this.layout[id]; + let acc = this.accelerator_for_key(key.name,m); svg_html += ``; svg_html += ``; svg_html += `${key.name.toUpperCase()}`; @@ -86,7 +86,7 @@ function Controller() this.documentation = function() { - var txt = ""; + let txt = ""; txt += this.documentation_for_mode("default",this.menu.default); @@ -99,13 +99,13 @@ function Controller() this.documentation_for_mode = function(name,mode) { - var txt = `## ${name} Mode\n\n`; + let txt = `## ${name} Mode\n\n`; - for(id in mode){ + for(let id in mode){ if(id == "*"){ continue; } txt += `### ${id}\n`; - for(name in mode[id]){ - var option = mode[id][name]; + for(let name in mode[id]){ + let option = mode[id][name]; txt += `- ${name}: \`${option.accelerator}\`\n`; } txt += "\n" @@ -116,11 +116,11 @@ function Controller() this.accelerator_for_key = function(key,menu) { - var acc = {basic:null,ctrl:null} - for(cat in menu){ - var options = menu[cat]; - for(id in options.submenu){ - var option = options.submenu[id]; if(option.role){ continue; } + let acc = {basic:null,ctrl:null} + for(let cat in menu){ + let options = menu[cat]; + for(let id in options.submenu){ + let option = options.submenu[id]; if(option.role){ continue; } acc.basic = (option.accelerator.toLowerCase() == key.toLowerCase()) ? option.label.toUpperCase().replace("TOGGLE ","").substr(0,8).trim() : acc.basic; acc.ctrl = (option.accelerator.toLowerCase() == ("CmdOrCtrl+"+key).toLowerCase()) ? option.label.toUpperCase().replace("TOGGLE ","").substr(0,8).trim() : acc.ctrl; } diff --git a/desktop/sources/scripts/lib/theme.js b/desktop/sources/scripts/lib/theme.js index a3b3180..a6dbbf9 100644 --- a/desktop/sources/scripts/lib/theme.js +++ b/desktop/sources/scripts/lib/theme.js @@ -1,6 +1,6 @@ function Theme() { - var app = this; + let app = this; this.el = document.createElement("style"); this.el.type = 'text/css'; @@ -17,7 +17,7 @@ function Theme() this.load = function(t, fall_back) { - var theme = is_json(t) ? JSON.parse(t).data : t.data; + let theme = is_json(t) ? JSON.parse(t).data : t.data; if(!theme || !theme.background){ if(fall_back) { @@ -27,7 +27,7 @@ function Theme() } } - var css = ` + let css = ` :root { --background: ${theme.background}; --f_high: ${theme.f_high}; @@ -62,11 +62,11 @@ function Theme() e.preventDefault(); e.stopPropagation(); - var file = e.dataTransfer.files[0]; + let file = e.dataTransfer.files[0]; if(!file.name || !file.name.indexOf(".thm") < 0){ console.log("Theme","Not a theme"); return; } - var reader = new FileReader(); + let reader = new FileReader(); reader.onload = function(e){ app.load(e.target.result); }; diff --git a/desktop/sources/scripts/picker.js b/desktop/sources/scripts/picker.js index 7f6d3ac..04cdfe4 100644 --- a/desktop/sources/scripts/picker.js +++ b/desktop/sources/scripts/picker.js @@ -32,7 +32,7 @@ function Picker() this.validate = function() { - var parts = this.parse(this.el.value) + let parts = this.parse(this.el.value) if(parts.color){ this.set_color(parts.color); } if(parts.size){ this.set_size(parts.size); } @@ -70,7 +70,7 @@ function Picker() this.update = function() { - var parts = this.parse(this.el.value) + let parts = this.parse(this.el.value) if(!parts.color){ return; } dotgrid.tool.style().color = parts.color; @@ -91,12 +91,12 @@ function Picker() this.parse = function(value) { - var parts = value.split(" "); - var color = null; - var size = null; + let parts = value.split(" "); + let color = null; + let size = null; - for(id in parts){ - var part = parts[id]; + for(let id in parts){ + let part = parts[id]; if(is_color(part) && !color){ color = part; } if(is_size(part) && !size){ size = { width:parseInt(part.toLowerCase().split("x")[0]),height:parseInt(part.toLowerCase().split("x")[1]) }; } } @@ -116,7 +116,7 @@ function Picker() return false } - var re = /\#[0-9A-Fa-f]/g; + let re = /\#[0-9A-Fa-f]/g; return re.test(val) } diff --git a/desktop/sources/scripts/renderer.js b/desktop/sources/scripts/renderer.js index deffa3c..c801ca1 100644 --- a/desktop/sources/scripts/renderer.js +++ b/desktop/sources/scripts/renderer.js @@ -23,8 +23,8 @@ function Renderer() this.svg_el.style.height = dotgrid.tool.settings.size.height+(10); this.svg_el.style.strokeWidth = dotgrid.tool.style().thickness; - var styles = dotgrid.tool.styles - var paths = dotgrid.tool.paths() + let styles = dotgrid.tool.styles + let paths = dotgrid.tool.paths() this.layer_1.style.strokeWidth = styles[0].thickness; this.layer_1.style.strokeLinecap = styles[0].strokeLinecap; @@ -54,22 +54,22 @@ function Renderer() this.refresh(); - var xml = new XMLSerializer().serializeToString(this.svg_el); - var svg64 = btoa(xml); - var b64Start = 'data:image/svg+xml;base64,'; - var image64 = b64Start + svg64; - var img = new Image; + let xml = new XMLSerializer().serializeToString(this.svg_el); + let svg64 = btoa(xml); + let b64Start = 'data:image/svg+xml;base64,'; + let image64 = b64Start + svg64; + let img = new Image; - var canvas = document.createElement("canvas"); + let canvas = document.createElement("canvas"); canvas.width = (size.width)*2; canvas.height = (size.height+30)*2; - var ctx = canvas.getContext('2d'); + let ctx = canvas.getContext('2d'); img.onload = function(){ ctx.drawImage(img, 0, 0, (size.width)*2, (size.height+30)*2); - var data = canvas.toDataURL('image/png').replace(/^data:image\/\w+;base64,/, ""); + let data = canvas.toDataURL('image/png').replace(/^data:image\/\w+;base64,/, ""); dotgrid.renderer.to_png_ready(callback, new Buffer(data, 'base64'),size) }; img.src = image64; @@ -84,16 +84,16 @@ function Renderer() { this.refresh(); - var xml = new XMLSerializer().serializeToString(this.svg_el); - var svg64 = btoa(xml); - var b64Start = 'data:image/svg+xml;base64,'; - var image64 = b64Start + svg64; + let xml = new XMLSerializer().serializeToString(this.svg_el); + let svg64 = btoa(xml); + let b64Start = 'data:image/svg+xml;base64,'; + let image64 = b64Start + svg64; - var canvas = document.createElement("canvas"); - var ctx = canvas.getContext('2d'); + let canvas = document.createElement("canvas"); + let ctx = canvas.getContext('2d'); - var win = window.open('about:blank','image from canvas'); - var img = new Image; + let win = window.open('about:blank','image from canvas'); + let img = new Image; canvas.width = size.width*2; canvas.height = size.height*2; diff --git a/desktop/sources/scripts/tool.js b/desktop/sources/scripts/tool.js index d88360e..ba76359 100644 --- a/desktop/sources/scripts/tool.js +++ b/desktop/sources/scripts/tool.js @@ -102,10 +102,10 @@ function Tool() this.remove_segments_at = function(pos) { - for(segment_id in this.layer()){ - var segment = this.layer()[segment_id]; - for(vertex_id in segment.vertices){ - var vertex = segment.vertices[vertex_id]; + for(let segment_id in this.layer()){ + let segment = this.layer()[segment_id]; + for(let vertex_id in segment.vertices){ + let vertex = segment.vertices[vertex_id]; if(Math.abs(pos.x) == Math.abs(vertex.x) && Math.abs(pos.y) == Math.abs(vertex.y)){ segment.vertices.splice(vertex_id,1) } @@ -128,10 +128,10 @@ function Tool() this.vertex_at = function(pos) { - for(segment_id in this.layer()){ - var segment = this.layer()[segment_id]; - for(vertex_id in segment.vertices){ - var vertex = segment.vertices[vertex_id]; + for(let segment_id in this.layer()){ + let segment = this.layer()[segment_id]; + for(let vertex_id in segment.vertices){ + let vertex = segment.vertices[vertex_id]; if(vertex.x == Math.abs(pos.x) && vertex.y == Math.abs(pos.y)){ return vertex; } @@ -145,7 +145,7 @@ function Tool() if(!this.layer()){ this.layers[this.index] = []; } if(!this.can_cast(type)){ console.warn("Cannot cast"); return; } - var append_target = this.can_append({type:type,vertices:this.vertices.slice()}) + let append_target = this.can_append({type:type,vertices:this.vertices.slice()}) if(append_target){ this.layers[this.index][append_target].vertices = this.layers[this.index][append_target].vertices.concat(this.vertices.slice()) @@ -168,12 +168,12 @@ function Tool() this.toggle = function(type,mod = 1) { if(type == "linecap"){ - var a = ["butt","square","round"]; + let a = ["butt","square","round"]; this.i.linecap += mod; this.style().strokeLinecap = a[this.i.linecap % a.length]; } else if(type == "linejoin"){ - var a = ["miter","round","bevel"]; + let a = ["miter","round","bevel"]; this.i.linejoin += mod; this.style().strokeLinejoin = a[this.i.linejoin % a.length]; } @@ -211,8 +211,8 @@ function Tool() this.can_append = function(content) { - for(id in this.layer()){ - var stroke = this.layer()[id]; + for(let id in this.layer()){ + let stroke = this.layer()[id]; if(stroke.type != content.type){ continue; } if(!stroke.vertices){ continue; } if(!stroke.vertices[stroke.vertices.length-1]){ continue; } @@ -228,7 +228,7 @@ function Tool() if(!type){ return false; } // Cannot cast close twice if(type == "close"){ - var prev = this.layer()[this.layer().length-1]; + let prev = this.layer()[this.layer().length-1]; if(!prev || prev.type == "close"){ return false; } @@ -243,9 +243,9 @@ function Tool() this.paths = function() { - var l1 = new Generator(dotgrid.tool.layers[0],dotgrid.tool.styles[0]).toString({x:-10,y:-10},1) - var l2 = new Generator(dotgrid.tool.layers[1],dotgrid.tool.styles[1]).toString({x:-10,y:-10},1) - var l3 = new Generator(dotgrid.tool.layers[2],dotgrid.tool.styles[2]).toString({x:-10,y:-10},1) + let l1 = new Generator(dotgrid.tool.layers[0],dotgrid.tool.styles[0]).toString({x:-10,y:-10},1) + let l2 = new Generator(dotgrid.tool.layers[1],dotgrid.tool.styles[1]).toString({x:-10,y:-10},1) + let l3 = new Generator(dotgrid.tool.layers[2],dotgrid.tool.styles[2]).toString({x:-10,y:-10},1) return [l1,l2,l3] } @@ -257,10 +257,10 @@ function Tool() this.translate = function(a,b) { - for(segment_id in this.layer()){ - var segment = this.layer()[segment_id]; - for(vertex_id in segment.vertices){ - var vertex = segment.vertices[vertex_id]; + for(let segment_id in this.layer()){ + let segment = this.layer()[segment_id]; + for(let vertex_id in segment.vertices){ + let vertex = segment.vertices[vertex_id]; if(vertex.x == Math.abs(a.x) && vertex.y == Math.abs(a.y)){ segment.vertices[vertex_id] = {x:Math.abs(b.x),y:Math.abs(b.y)}; } @@ -273,12 +273,12 @@ function Tool() this.translate_multi = function(a,b) { - var offset = {x:a.x - b.x,y:a.y - b.y} + let offset = {x:a.x - b.x,y:a.y - b.y} - for(segment_id in this.layer()){ - var segment = this.layer()[segment_id]; - for(vertex_id in segment.vertices){ - var vertex = segment.vertices[vertex_id]; + for(let segment_id in this.layer()){ + let segment = this.layer()[segment_id]; + for(let vertex_id in segment.vertices){ + let vertex = segment.vertices[vertex_id]; segment.vertices[vertex_id] = {x:vertex.x-offset.x,y:vertex.y-offset.y}; } } diff --git a/index.html b/index.html index 70be766..5494334 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,7 @@
diff --git a/web/events.js b/web/events.js index 668b572..fc032ab 100644 --- a/web/events.js +++ b/web/events.js @@ -1,6 +1,6 @@ document.onkeyup = (e) => { - var ch = e.key.toLowerCase(); + let ch = e.key.toLowerCase(); if(e.target && e.target.id == "picker"){ return; }