Skip to content

Commit

Permalink
delete temp polygon area with escape key
Browse files Browse the repository at this point in the history
  • Loading branch information
n-peugnet committed Nov 11, 2018
1 parent 465c01a commit 1b2c7b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/image-map-creator.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/class.area.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class Area {
}
}

empty() {
isEmpty() {
return this.coords.length == 0;
}

Expand Down
8 changes: 5 additions & 3 deletions src/p5.image-map-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class imageMapCreator {
this.setTempArea(this.mX(), this.mY());
break;
case "polygon":
if (this.tempArea.empty()) {
if (this.tempArea.isEmpty()) {
this.setTempArea(this.mX(), this.mY());
} else if (this.tempArea.isClosable(this.mX(), this.mY(), 5 / this.view.scale)) {
this.tempArea.close();
Expand Down Expand Up @@ -212,6 +212,8 @@ export class imageMapCreator {
return true;
}
return false;
} else if (this.tool == "polygon" && e.keyCode == this.p5.ESCAPE) {
this.tempArea = new Area();
}
}
}
Expand Down Expand Up @@ -359,7 +361,7 @@ export class imageMapCreator {
if (this.drawingTools.includes(this.tool)) {
switch (this.tool) {
case "polygon":
if (!this.tempArea.empty() && this.tempArea.isClosable(this.mX(), this.mY(), 5 / this.view.scale)) {
if (!this.tempArea.isEmpty() && this.tempArea.isClosable(this.mX(), this.mY(), 5 / this.view.scale)) {
this.p5.cursor(this.p5.HAND);
break;
}
Expand Down Expand Up @@ -455,7 +457,7 @@ export class imageMapCreator {
}

updateTempArea() {
if (!this.tempArea.empty()) {
if (!this.tempArea.isEmpty()) {
this.tempArea.updateLastCoord(this.mX(), this.mY());
}
}
Expand Down

1 comment on commit 1b2c7b7

@n-peugnet
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implements #6

Please sign in to comment.