Added cursor drag
This commit is contained in:
@@ -61,7 +61,10 @@ function Cursor(rune)
|
||||
|
||||
}
|
||||
else if(e.altKey){
|
||||
ronin.eraser.stroke(ronin.cursor.line);
|
||||
ronin.brush.erase(ronin.cursor.line);
|
||||
}
|
||||
else if(e.shiftKey){
|
||||
ronin.cursor.drag(ronin.cursor.line);
|
||||
}
|
||||
else{
|
||||
ronin.brush.stroke(ronin.cursor.line);
|
||||
@@ -91,6 +94,20 @@ function Cursor(rune)
|
||||
ronin.cursor.query = ronin.commander.input_el.value;
|
||||
}
|
||||
|
||||
this.drag = function(line)
|
||||
{
|
||||
var offset = make_offset(line.from,line.to);
|
||||
var data = ronin.render.select();
|
||||
ronin.render.clear();
|
||||
ronin.render.context().putImageData(data, offset.x * -2, offset.y * -2);
|
||||
}
|
||||
|
||||
function make_offset(a,b)
|
||||
{
|
||||
return {x:a.x-b.x,y:a.y-b.y};
|
||||
}
|
||||
|
||||
|
||||
this.inject_query = function()
|
||||
{
|
||||
if(ronin.cursor.query && ronin.cursor.query.indexOf("$") < 0){ return; }
|
||||
|
||||
@@ -28,12 +28,12 @@ function Layer()
|
||||
this.el.style.height = size.height+"px";
|
||||
}
|
||||
|
||||
this.select = function(x,y,width,height)
|
||||
this.select = function(x = 0,y = 0,width = ronin.frame.settings.width,height = ronin.frame.settings.width)
|
||||
{
|
||||
return this.context().getImageData(x, y, width * 2, height * 2);
|
||||
}
|
||||
|
||||
this.to_data = function()
|
||||
this.to_base64 = function()
|
||||
{
|
||||
return this.el.toDataURL('image/png');
|
||||
}
|
||||
@@ -41,7 +41,7 @@ function Layer()
|
||||
this.to_img = function()
|
||||
{
|
||||
var img = new Image();
|
||||
img.src = this.to_data();
|
||||
img.src = this.to_base64();
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user