From 53898a5881836779b41ad74dc6383240173c84dd Mon Sep 17 00:00:00 2001
From: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Mon, 19 Dec 2016 10:14:07 -0700
Subject: [PATCH] Migrated brush mouse events into cursor.paint

---
 scripts/modes/mode.paint.js | 23 ++++++++++++++++++++---
 scripts/modules/brush.js    | 34 +---------------------------------
 2 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/scripts/modes/mode.paint.js b/scripts/modes/mode.paint.js
index ad3325c..f32b16a 100644
--- a/scripts/modes/mode.paint.js
+++ b/scripts/modes/mode.paint.js
@@ -4,18 +4,35 @@ function Mode_Paint()
   
   this.name = "Paint";
   
+  this.is_drawing = false;
+  
   this.mouse_down = function(event)
   {
-    ronin.brush.draw_start(event); ronin.brush.draw(event);
+    this.is_drawing = true;
+    
+    for (i = 0; i < ronin.brush.pointers.length; i++) {
+      ronin.brush.pointers[i].start();
+    }
   }
   
   this.mouse_move = function(event)
   {
-    ronin.brush.draw(event);
+    if(this.is_drawing === false){return;}
+    
+    // this.position = new Position(event.clientX - parseFloat(ronin.surface.style.left) - parseFloat(ronin.canvas.element.style.left),event.clientY- parseFloat(ronin.surface.style.top) - parseFloat(ronin.canvas.element.style.top));
+    ronin.brush.position = ronin.position_in_canvas(event);
+    
+    for (i = 0; i < ronin.brush.pointers.length; i++) {
+      ronin.brush.pointers[i].draw();
+    }
   }
   
   this.mouse_up = function(event)
   {
-    ronin.brush.draw_stop(event);
+    this.is_drawing = false;
+    
+    for (i = 0; i < ronin.brush.pointers.length; i++) {
+      ronin.brush.pointers[i].stop();
+    }
   }
 }
\ No newline at end of file
diff --git a/scripts/modules/brush.js b/scripts/modules/brush.js
index 471bd0f..b0ea0da 100644
--- a/scripts/modules/brush.js
+++ b/scripts/modules/brush.js
@@ -6,7 +6,6 @@ function Brush(rune)
   this.pointers = [new Pointer(new Position())];
   
   this.position = new Position();
-  this.is_drawing = false;
   this.size = 1;
   this.opacity = 1;
   this.color = new Color();
@@ -61,38 +60,7 @@ function Brush(rune)
   {
     this.pointers.push(pointer);
   }
-  
-  // Draw
-  
-  this.draw = function(e)
-  {
-    if(this.is_drawing === false){return;}
-    
-    this.position = new Position(e.clientX - parseFloat(ronin.surface.style.left) - parseFloat(ronin.canvas.element.style.left),e.clientY- parseFloat(ronin.surface.style.top) - parseFloat(ronin.canvas.element.style.top));
-    
-    for (i = 0; i < this.pointers.length; i++) {
-      this.pointers[i].draw();
-    }
-  }
-  
-  this.draw_start = function(e)
-  {
-    this.is_drawing = true;
-    
-    for (i = 0; i < this.pointers.length; i++) {
-      this.pointers[i].start();
-    }
-  }
-  
-  this.draw_stop = function(e)
-  {
-    this.is_drawing = false;
-    
-    for (i = 0; i < this.pointers.length; i++) {
-      this.pointers[i].stop();
-    }
-  }
-  
+
   this.widget = function()
   {
     return "> "+this.size+" <span style='color:"+this.color.render()+"'>"+this.color.render()+"</span> ";