diff --git a/BUILD.md b/BUILD.md index 55f42f1..9957f98 100644 --- a/BUILD.md +++ b/BUILD.md @@ -27,11 +27,12 @@ cd /xxiivv/Nataniev/public/public.projects/builds/ ~/butler push /xxiivv/Nataniev/public/public.projects/builds/Dotgrid-win32-x64/ hundredrabbits/dotgrid:windows-64 ~/butler push /xxiivv/Nataniev/public/public.projects/builds/Dotgrid-darwin-x64/ hundredrabbits/dotgrid:osx-64 +~/butler status hundredrabbits/dotgrid + rm -r /xxiivv/Nataniev/public/public.projects/builds/Dotgrid-darwin-x64/ rm -r /xxiivv/Nataniev/public/public.projects/builds/Dotgrid-linux-x64/ rm -r /xxiivv/Nataniev/public/public.projects/builds/Dotgrid-win32-x64/ -~/butler status hundredrabbits/dotgrid ``` @@ -52,3 +53,27 @@ electron-packager . Dotgrid --platform=linux --arch=x64 --out /Users/VillaMoirai cd /Users/VillaMoirai/Github/HundredRabbits/Dotgrid/ electron-packager . Dotgrid --platform=win32 --arch=x64 --out /Users/VillaMoirai/Desktop/ --overwrite --electron-version=1.7.5 --icon=icon.ico ``` + +### Build +``` +cd /Users/VillaMoirai/Desktop/ +rm -r /Users/VillaMoirai/Desktop/Dotgrid-darwin-x64/ +rm -r /Users/VillaMoirai/Desktop/Ronin-darwin-x64/ +rm -r /Users/VillaMoirai/Desktop/Left-darwin-x64/ +rm -r /Users/VillaMoirai/Desktop/Marabu-darwin-x64/ + +cd /Users/VillaMoirai/Github/HundredRabbits/Dotgrid/ +electron-packager . Dotgrid --platform=darwin --arch=x64 --out /Users/VillaMoirai/Desktop/ --overwrite --electron-version=1.7.5 --icon=icon.icns + +cd /Users/VillaMoirai/Github/HundredRabbits/Ronin/ +electron-packager . Ronin --platform=darwin --arch=x64 --out /Users/VillaMoirai/Desktop/ --overwrite --electron-version=1.7.5 --icon=icon.icns + +cd /Users/VillaMoirai/Github/HundredRabbits/Left/ +electron-packager . Left --platform=darwin --arch=x64 --out /Users/VillaMoirai/Desktop/ --overwrite --electron-version=1.7.5 --icon=icon.icns + +cd /Users/VillaMoirai/Github/HundredRabbits/Marabu/ +electron-packager . Marabu --platform=darwin --arch=x64 --out /Users/VillaMoirai/Desktop/ --overwrite --electron-version=1.7.5 --icon=icon.icns +``` + + + diff --git a/README.md b/README.md index e3a44f7..97fd003 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,11 @@ It works by adding control points and selecting a stroke type. So clicking the c - `-` Reduce stroke size. - `/` Toggle linecap. +### Shortcuts + +- `ctrl+n` New canvas. +- `alt+click` Erase target stroke. + ## License See the [LICENSE](LICENSE.md) file for license rights and limitations (CC). diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index 6dc75ae..0d3bf3c 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -136,6 +136,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca var pos = this.position_in_grid(new Pos(e.clientX,e.clientY)); pos = this.position_on_grid(pos); + if(e.altKey){ dotgrid.delete_at(pos); return; } if(pos.x>0) return; if(from === null){ this.set_from(pos); } @@ -170,6 +171,21 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca end = pos; } + this.delete_at = function(pos) + { + var segs = []; + + for(id in this.segments){ + var s = this.segments[id]; + if(s.from && s.from.is_equal(pos)){ continue; } + if(s.to && s.to.is_equal(pos)){ continue; } + if(s.end && s.end.is_equal(pos)){ continue; } + segs.push(s); + } + this.segments = segs; + this.draw(); + } + this.mod_thickness = function(mod) { this.thickness = Math.max(this.thickness+mod,0); @@ -253,7 +269,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.segments.push(new Path_Line(from,to,end)); this.draw(); - reset(); + this.reset(); } this.draw_arc = function(orientation) @@ -267,7 +283,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.segments.push(new Path_Arc(from,to,orientation,end)); this.draw(); - reset(); + this.reset(); } this.draw_bezier = function() @@ -281,7 +297,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.segments.push(new Path_Bezier(from,to,end)); this.draw(); - reset(); + this.reset(); } this.draw_close = function() @@ -292,15 +308,10 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.segments.push(new Path_Close()); this.draw(); - reset(); + this.reset(); } this.reset = function() - { - reset(); - } - - function reset() { from = null; to = null; @@ -313,6 +324,16 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca cursor_end.style.top = -100; } + this.clear = function() + { + this.reset(); + this.segments = []; + this.thickness = 10 + this.linecap = "square" + this.color = "#000000" + this.draw(); + } + this.erase = function() { if(from || to || end){ diff --git a/sources/scripts/keyboard.js b/sources/scripts/keyboard.js index 0186786..4ab1eba 100644 --- a/sources/scripts/keyboard.js +++ b/sources/scripts/keyboard.js @@ -14,6 +14,12 @@ function Keyboard() return; } + // new + if(e.key == "n" && (e.ctrlKey || e.metaKey)){ + dotgrid.clear(); + return; + } + // Reset if((e.key == "Backspace" || e.key == "Delete") && e.ctrlKey && e.shiftKey){ e.preventDefault(); diff --git a/sources/scripts/pos.js b/sources/scripts/pos.js index 87a97ee..98bdf71 100644 --- a/sources/scripts/pos.js +++ b/sources/scripts/pos.js @@ -20,6 +20,6 @@ function Pos(x,y) this.is_equal = function(pos2) { - return pos2.x == this.x && pos2.y == this.y; + return Math.abs(pos2.x) == Math.abs(this.x) && Math.abs(pos2.y) == Math.abs(this.y); } } \ No newline at end of file