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+" "+this.color.render()+" ";