Removed the cursor layer

This commit is contained in:
Devine Lu Linvega 2018-01-27 21:27:48 +13:00
parent 5615e8de87
commit ab2406247c
5 changed files with 17 additions and 41 deletions
sources

@ -1,8 +1,6 @@
body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_medium",courier,monospace; background:000;}
*:focus {outline: none; }
canvas { cursor: none }
yu { display:block; }
#cursor { z-index:899; position: absolute; }

@ -1,8 +1,5 @@
function Cursor(rune)
{
Layer.call(this);
this.el.id = "cursor";
this.line = {origin:null,from:null,to:null,destination:null};
this.is_down = false;
this.query = null;
@ -15,26 +12,6 @@ function Cursor(rune)
this.target = null;
this.draw_cursor = function(pos,touch = false)
{
this.clear();
if(!pos){ return; }
var ctx = this.context();
var radius = ronin.cursor.size * ronin.frame.zoom.scale;
ctx.beginPath();
ctx.arc(pos.x * 2, pos.y * 2, radius, 0, 2 * Math.PI, false);
ctx.strokeStyle = "#000";
ctx.lineWidth = 4.5;
ctx.stroke();
ctx.strokeStyle = touch ? "#000" : "#fff";
ctx.lineWidth = 1.5;
ctx.stroke();
ctx.closePath();
}
this.mouse_pos = function(e)
{
var pos = {x:e.clientX,y:e.clientY};
@ -65,8 +42,6 @@ function Cursor(rune)
return;
}
ronin.cursor.draw_cursor({x:e.clientX,y:e.clientY},true);
ronin.cursor.line.origin = {x:pos.x,y:pos.y};
ronin.cursor.line.from = {x:pos.x,y:pos.y};
@ -75,7 +50,7 @@ function Cursor(rune)
if(ronin.commander.active_module()){ }
else if(e.altKey && e.shiftKey){ ronin.brush.methods.pick.run(pos); }
else if(e.shiftKey){ }
else if(e.altKey){ ronin.brush.erase(ronin.cursor.line); }
else{ ronin.brush.stroke(ronin.cursor.line); }
if(e.shiftKey){ ronin.cursor.mode = "rect"; }
@ -89,7 +64,6 @@ function Cursor(rune)
var pos = ronin.cursor.mouse_pos(e);
ronin.cursor.pos = pos;
ronin.cursor.draw_cursor({x:pos.x,y:pos.y});
if(!ronin.cursor.line.from){ return; }
@ -97,6 +71,7 @@ function Cursor(rune)
if(e.altKey && e.shiftKey){ ronin.brush.methods.pick.run(pos); }
else if(e.shiftKey){ ronin.cursor.drag(ronin.cursor.line); }
else if(e.altKey){ ronin.brush.erase(ronin.cursor.line); }
else{ ronin.brush.stroke(ronin.cursor.line); }
ronin.cursor.inject_query();
@ -110,7 +85,6 @@ function Cursor(rune)
var pos = ronin.cursor.mouse_pos(e);
ronin.cursor.pos = pos;
ronin.cursor.draw_cursor({x:pos.x,y:pos.y});
ronin.cursor.line.destination = {x:pos.x,y:pos.y};

@ -49,6 +49,15 @@ function Brush()
}
}
this.erase = function(line)
{
this.speed = distance_between(line.from,line.to);
for(pointer_id in this.pointers){
this.pointers[pointer_id].stroke(line,true);
}
}
this.pick = function(line)
{
if(!line.to){
@ -88,7 +97,7 @@ function Pointer(options)
return ronin.cursor.color;
}
this.stroke = function(line)
this.stroke = function(line,erase = false)
{
var ctx = ronin.cursor.target.context();
@ -101,10 +110,8 @@ function Pointer(options)
line.to = line.from
}
var ratio = clamp((ronin.brush.speed/20),0,1)
ctx.beginPath();
ctx.globalCompositeOperation = ronin.keyboard.is_down["Alt"] ? "destination-out" : "source-over";
ctx.globalCompositeOperation = erase ? "destination-out" : "source-over";
ctx.moveTo((line.from.x * 2) + this.options.offset.x,(line.from.y * 2) + this.options.offset.y);
ctx.lineTo((line.to.x * 2) + this.options.offset.x,(line.to.y * 2) + this.options.offset.y);
ctx.lineCap="round";

@ -90,6 +90,5 @@ function Frame()
ronin.layers.above.resize_to(size);
ronin.layers.below.resize_to(size);
ronin.guide.resize_to(size);
ronin.cursor.resize_to(size);
}
}

@ -54,7 +54,6 @@ function Ronin()
// this.guide.install();
this.above.install();
this.below.install();
this.cursor.install();
this.guide.install();
this.guide.update();
@ -102,10 +101,10 @@ function Ronin()
window.addEventListener('dragover', ronin.io.drag_over);
window.addEventListener('drop', ronin.io.drop);
ronin.cursor.el.addEventListener('mousedown', ronin.cursor.mouse_down);
ronin.cursor.el.addEventListener('mousemove', ronin.cursor.mouse_move);
ronin.cursor.el.addEventListener('mouseup', ronin.cursor.mouse_up);
ronin.cursor.el.addEventListener('contextmenu', ronin.cursor.mouse_alt);
ronin.frame.el.addEventListener('mousedown', ronin.cursor.mouse_down);
ronin.frame.el.addEventListener('mousemove', ronin.cursor.mouse_move);
ronin.frame.el.addEventListener('mouseup', ronin.cursor.mouse_up);
ronin.frame.el.addEventListener('contextmenu', ronin.cursor.mouse_alt);
window.addEventListener('keydown', ronin.keyboard.key_down);
window.addEventListener('keyup', ronin.keyboard.key_up);
ronin.commander.input_el.addEventListener('input', ronin.commander.on_input);
@ -114,7 +113,6 @@ function Ronin()
this.above.update();
this.below.update();
this.guide.update();
this.cursor.update();
this.commander.update();
this.frame.resize_to({width:930,height:540});