Fixed issue with close

This commit is contained in:
Devine Lu Linvega 2018-02-06 19:51:09 +13:00
parent d119160773
commit 36f5644c45
6 changed files with 7 additions and 18 deletions

View File

@ -6,16 +6,11 @@
- Save: `CmdOrCtrl+S`
### Edit
- Insert: `I`
- Copy: `CmdOrCtrl+C`
- Paste: `CmdOrCtrl+V`
- Undo: `CmdOrCtrl+Z`
- Redo: `CmdOrCtrl+Shift+Z`
- Delete: `Backspace`
- Move Up: `Up`
- Move Down: `Down`
- Move Left: `Left`
- Move Right: `Right`
- Deselect: `Esc`
### Stroke

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -18,16 +18,11 @@ Clicking on the canvas will insert control points, up to 3CPs. CPs can be moved
- Save: `CmdOrCtrl+S`
### Edit
- Insert: `I`
- Copy: `CmdOrCtrl+C`
- Paste: `CmdOrCtrl+V`
- Undo: `CmdOrCtrl+Z`
- Redo: `CmdOrCtrl+Shift+Z`
- Delete: `Backspace`
- Move Up: `Up`
- Move Down: `Down`
- Move Left: `Left`
- Move Right: `Right`
- Deselect: `Esc`
### Stroke

View File

@ -40,7 +40,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
this.mirror = false;
this.fill = false;
this.path = document.createElementNS("http://www.w3.org/2000/svg", "path");
this.segments = [];
this.scale = 1;
this.install = function()
@ -417,7 +416,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
{
this.history.clear();
this.reset();
this.segments = [];
this.thickness = 10
this.linecap = "round"
this.linejoin = "round"
@ -444,8 +442,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
this.copy = function(e)
{
if(dotgrid.segments.length == 0){ return; }
dotgrid.scale = 1
dotgrid.width = 300
dotgrid.height = 300

View File

@ -35,13 +35,12 @@ function Interface()
this.update = function()
{
let prev = dotgrid.segments[dotgrid.segments.length-1]
document.getElementById("line").className.baseVal = !dotgrid.tool.can_cast("line") ? "icon inactive" : "icon";
document.getElementById("arc_c").className.baseVal = !dotgrid.tool.can_cast("arc_c") ? "icon inactive" : "icon";
document.getElementById("arc_r").className.baseVal = !dotgrid.tool.can_cast("arc_r") ? "icon inactive" : "icon";
document.getElementById("bezier").className.baseVal = !dotgrid.tool.can_cast("bezier") ? "icon inactive" : "icon";
document.getElementById("close").className.baseVal = dotgrid.segments.length < 1 || (prev && prev.name == "close") ? "icon inactive" : "icon";
document.getElementById("close").className.baseVal = !dotgrid.tool.can_cast("close") ? "icon inactive" : "icon";
document.getElementById("thickness").className.baseVal = dotgrid.tool.layer().length < 1 ? "icon inactive" : "icon";
document.getElementById("linecap").className.baseVal = dotgrid.tool.layer().length < 1 ? "icon inactive" : "icon";

View File

@ -55,10 +55,11 @@ function Tool()
this.can_cast = function(type)
{
if(!type){ return false; }
// Cannot cast close twice
if(type == "close"){
var prev = this.layer()[this.layer().length-1];
if(prev.type == "close"){
if(!prev || prev.type == "close"){
return false;
}
}
@ -165,5 +166,8 @@ function Tool()
this.import = function(layers)
{
this.layers = layers;
dotgrid.history.push(this.layers);
this.clear();
dotgrid.draw();
}
}