Added eraser.
This commit is contained in:
@@ -65,6 +65,11 @@ function Brush(rune)
|
||||
return "> "+this.size+" <span>"+this.color.render()+"</span> ";
|
||||
}
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Brush "+this.size;
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.is_drawing = false;
|
||||
|
@@ -16,6 +16,8 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
||||
this.distance += position.distance_to(this.position_prev);
|
||||
|
||||
ronin.canvas.context().beginPath();
|
||||
|
||||
ronin.canvas.context().globalCompositeOperation="source-over";
|
||||
ronin.canvas.context().moveTo(this.position_prev.x,this.position_prev.y);
|
||||
ronin.canvas.context().lineTo(position.x,position.y);
|
||||
ronin.canvas.context().lineCap="round";
|
||||
|
@@ -68,6 +68,11 @@ function Canvas(rune)
|
||||
return "@ "+this.element.width+"x"+this.element.height+" ";
|
||||
}
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Drag";
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.drag_from = null;
|
||||
|
79
scripts/modules/eraser.js
Normal file
79
scripts/modules/eraser.js
Normal file
@@ -0,0 +1,79 @@
|
||||
function Eraser(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Value];
|
||||
this.size = 5;
|
||||
|
||||
// Module
|
||||
|
||||
this.position_prev = null;
|
||||
|
||||
this.draw = function()
|
||||
{
|
||||
if(!this.position_prev){this.position_prev = ronin.cursor.position; }
|
||||
if(ronin.brush.size < 0){ this.erase(); return; }
|
||||
|
||||
var position = ronin.cursor.position;
|
||||
|
||||
this.distance += position.distance_to(this.position_prev);
|
||||
|
||||
ronin.canvas.context().beginPath();
|
||||
ronin.canvas.context().globalCompositeOperation="destination-out";
|
||||
ronin.canvas.context().moveTo(this.position_prev.x,this.position_prev.y);
|
||||
ronin.canvas.context().lineTo(position.x,position.y);
|
||||
ronin.canvas.context().lineCap="round";
|
||||
ronin.canvas.context().lineWidth = 10;
|
||||
ronin.canvas.context().strokeStyle = new Color("#ff0000").rgba();
|
||||
ronin.canvas.context().stroke();
|
||||
ronin.canvas.context().closePath();
|
||||
|
||||
this.position_prev = position;
|
||||
}
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
if(cmd.value()){
|
||||
this.size = cmd.value().float;
|
||||
}
|
||||
}
|
||||
|
||||
this.passive = function(cmd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Eraser "+this.size;
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.is_drawing = false;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.is_drawing = true;
|
||||
this.position_prev = null;
|
||||
|
||||
ronin.stroke.new_stroke();
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(this.is_drawing === false){ return; }
|
||||
|
||||
this.draw();
|
||||
|
||||
ronin.stroke.append_stroke(position);
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
this.is_drawing = false;
|
||||
this.position_prev = null;
|
||||
|
||||
ronin.stroke.save_stroke();
|
||||
}
|
||||
}
|
@@ -25,6 +25,10 @@ function Module(rune)
|
||||
return "";
|
||||
}
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Missing";
|
||||
}
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
|
@@ -152,4 +152,11 @@ function Overlay(rune)
|
||||
this.live_draw_from = null;
|
||||
commander.element_input.focus();
|
||||
}
|
||||
|
||||
// Widget
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Guide";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user