Shortcut to move canvas content.

This commit is contained in:
Devine Lu Linvega
2016-12-21 08:48:21 -07:00
parent bfaa5310f6
commit c6b6d6a080
7 changed files with 87 additions and 18 deletions

View File

@@ -5,9 +5,13 @@ function Cursor()
this.update = function(event)
{
if(event.ctrlKey === true){ this.set_mode(ronin.overlay); }
else if(event.altKey === true){ this.set_mode(ronin.canvas); }
else if(event.shiftKey === true){ this.set_mode(ronin.eraser); }
if(event.ctrltKey === true && event.altKey === true && event.shiftKey === true){ /* */ }
else if(event.shiftKey === true && event.ctrlKey === true){ this.set_mode(ronin.planner); }
else if(event.shiftKey === true && event.altKey === true){ this.set_mode(ronin.canvas); }
else if(event.ctrltKey === true && event.altKey === true){ /* */ }
else if(event.ctrlKey === true){ this.set_mode(ronin.overlay); }
else if(event.altKey === true){ this.set_mode(ronin.surface); }
else if(event.shiftKey === true){ this.set_mode(ronin.eraser); }
else{ this.set_mode(ronin.brush); }
}

View File

@@ -1,7 +1,7 @@
var ronin = new Ronin();
ronin.canvas.element = document.getElementById('workspace');
ronin.overlay.element = document.getElementById('overlay');
ronin.surface = document.getElementById('surface');
ronin.surface.element = document.getElementById('surface');
ronin.widget.element = document.getElementById('widget');
ronin.cursor.mode = ronin.brush;

View File

@@ -3,7 +3,6 @@ function Ronin()
this.modules = {};
this.widget = new Widget();
this.surface = null;
this.canvas = new Canvas("@");
this.overlay = new Overlay("|");
@@ -16,6 +15,8 @@ function Ronin()
this.help = new Help("?");
this.history = new History("^");
this.eraser = new Eraser(".");
this.planner = new Planner("*");
this.surface = new Surface("#");
this.cursor = new Cursor();
@@ -30,19 +31,21 @@ function Ronin()
this.modules[this.help.rune] = this.help;
this.modules[this.history.rune] = this.history;
this.modules[this.eraser.rune] = this.eraser;
this.modules[this.planner.rune] = this.planner;
this.modules[this.surface.rune] = this.surface;
this.cursors = [];
this.position_in_canvas = function(e)
{
var x = e.clientX - parseFloat(ronin.surface.style.left) - parseFloat(ronin.canvas.element.style.left);
var y = e.clientY- parseFloat(ronin.surface.style.top) - parseFloat(ronin.canvas.element.style.top);
var x = e.clientX - parseFloat(ronin.surface.element.style.left) - parseFloat(ronin.canvas.element.style.left);
var y = e.clientY- parseFloat(ronin.surface.element.style.top) - parseFloat(ronin.canvas.element.style.top);
return new Position(x+","+y);
}
this.position_in_window = function(p)
{
return new Position(p.x + parseFloat(ronin.surface.style.left) + parseFloat(ronin.canvas.element.style.left),p.y + parseFloat(ronin.surface.style.top) + parseFloat(ronin.canvas.element.style.top));
return new Position(p.x + parseFloat(ronin.surface.element.style.left) + parseFloat(ronin.canvas.element.style.left),p.y + parseFloat(ronin.surface.element.style.top) + parseFloat(ronin.canvas.element.style.top));
}
this.timestamp = function()