summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/map/tools/eraser.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-10-28 18:06:46 -0400
committerJules Laplace <jules@okfoc.us>2016-10-28 18:06:46 -0400
commit9e7bacd46c1e5d0e1c24433690d421ab3f3a11f2 (patch)
tree4d0cefa2780dfa4382f1ed2ea481b6aafbdbb15e /public/assets/javascripts/rectangles/engine/map/tools/eraser.js
parent50da9e3e677f121f15e501bf062da6c45db255ad (diff)
parentcce1dea756717f1308c6b72f762b5ea5f5b43958 (diff)
merge
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/map/tools/eraser.js')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/tools/eraser.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/tools/eraser.js b/public/assets/javascripts/rectangles/engine/map/tools/eraser.js
new file mode 100644
index 0000000..8fc3687
--- /dev/null
+++ b/public/assets/javascripts/rectangles/engine/map/tools/eraser.js
@@ -0,0 +1,29 @@
+// Tool used to delete lines
+
+var EraserTool = MapTool.extend(function(base){
+ var exports = {}
+ exports.down = function(e, cursor){
+ last_point.a = cursor.x.a
+ last_point.b = cursor.y.a
+ var segment = shapes.findClosestSegment(last_point)
+ if (segment) {
+ shapes.removeSegment(segment)
+ }
+ }
+ exports.move = function(e, cursor){
+ last_point.a = cursor.x.a
+ last_point.b = cursor.y.a
+ var segment = shapes.findClosestSegment(last_point)
+ if (segment) {
+ document.body.style.cursor = "pointer"
+ last_point.a = segment.x
+ last_point.b = segment.y
+ cursor.x.a = cursor.x.b = last_point.a
+ cursor.y.a = cursor.y.b = last_point.b
+ }
+ else {
+ document.body.style.cursor = "crosshair"
+ }
+ }
+ return exports
+})