summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/map/tools/eraser.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-07-28 13:50:27 -0400
committerJules Laplace <jules@okfoc.us>2015-07-28 13:50:27 -0400
commit80723a9898ad237818ac04ae47ff801919f34961 (patch)
tree8aa7a9498b7bfedcd5a7ee17d8c83eb13c5aa2fd /public/assets/javascripts/rectangles/engine/map/tools/eraser.js
parent0a6a314dc01df3d8d7f37c6b97293cedeb1aa6a0 (diff)
split out modules
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/map/tools/eraser.js')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/tools/eraser.js27
1 files changed, 27 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..648cd11
--- /dev/null
+++ b/public/assets/javascripts/rectangles/engine/map/tools/eraser.js
@@ -0,0 +1,27 @@
+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
+})