diff --git a/index.html b/index.html
index 9361c98..0925a8f 100644
--- a/index.html
+++ b/index.html
@@ -5,6 +5,7 @@
+
diff --git a/scripts/commander.js b/scripts/commander.js
index 1e00ba1..53a2e1c 100644
--- a/scripts/commander.js
+++ b/scripts/commander.js
@@ -15,16 +15,15 @@ function Commander(element,element_input)
this.element_input.value = "";
}
- this.active = function(command)
+ this.active = function(cmd_array)
{
- var parts = command;
- var key = parts[0];
- parts.shift();
- var params = parts;
+ var key = cmd_array[0];
+ cmd_array.shift();
+ var cmd = new Command(cmd_array);
switch(key) {
case "@":
- ronin.canvas.active(params);
+ ronin.canvas.active(cmd);
break;
case "~":
ronin.history.active(params);
@@ -42,7 +41,7 @@ function Commander(element,element_input)
ronin.pointer.active(params);
break;
case "|":
- ronin.guide.active(params);
+ ronin.overlay.active(params);
break;
case "^":
ronin.translate.active(params);
@@ -111,16 +110,15 @@ function Commander(element,element_input)
*/
}
- this.passive = function(command)
+ this.passive = function(cmd_array)
{
- var parts = command;
- var key = parts[0];
- parts.shift();
- var params = parts;
+ var key = cmd_array[0];
+ cmd_array.shift();
+ var cmd = new Command(cmd_array);
switch(key) {
case "@":
- ronin.canvas.passive(params);
+ ronin.canvas.passive(cmd);
break;
case "~":
ronin.history.passive(params);
@@ -135,7 +133,7 @@ function Commander(element,element_input)
ronin.pointer.passive(params);
break;
case "|":
- ronin.guide.passive(params);
+ ronin.overlay.passive(params);
break;
case "^":
ronin.translate.passive(params);
diff --git a/scripts/ronin.canvas.js b/scripts/ronin.canvas.js
index 73e347e..8ff652a 100644
--- a/scripts/ronin.canvas.js
+++ b/scripts/ronin.canvas.js
@@ -4,28 +4,27 @@ function Canvas(element)
this.element = element;
- this.active = function(p)
+ this.active = function(cmd)
{
- if(p[0].indexOf("x") >= 0){
- var rect = new Rect(p[0]);
- this.resize(rect);
- ronin.overlay.resize(rect);
+ if(cmd.rect()){
+ this.resize(cmd.rect());
+ ronin.overlay.resize(cmd.rect());
}
- if(p.length > 1 && p[1].indexOf("#") >= 0){
- var color = new Color(p[1]);
- console.log(color);
-
+ if(cmd.color()){
+ console.log(cmd.color());
this.element.getContext('2d').beginPath();
this.element.getContext('2d').rect(0, 0, canvas.width, canvas.height);
- this.element.getContext('2d').fillStyle = color.hex;
+ this.element.getContext('2d').fillStyle = cmd.color().hex;
this.element.getContext('2d').fill();
}
}
- this.passive = function(p)
+ this.passive = function(cmd)
{
- console.log("TODO: Show guide");
+ if(cmd.rect()){
+ ronin.overlay.show_guide(null,cmd.rect());
+ }
}
//
diff --git a/scripts/ronin.overlay.js b/scripts/ronin.overlay.js
index e720d3c..70885fe 100644
--- a/scripts/ronin.overlay.js
+++ b/scripts/ronin.overlay.js
@@ -4,9 +4,43 @@ function Overlay(element)
this.element = element;
+ // Module
+
+ this.passive = function(p)
+ {
+ }
+
this.resize = function(rect)
{
this.element.setAttribute('width',rect.width+"px");
this.element.setAttribute('height',rect.height+"px");
}
+
+ this.show_guide = function(position,rect)
+ {
+ this.clear();
+ context.beginPath();
+
+ this.context().moveTo(0,0);
+ this.context().lineTo(rect.width,0);
+ this.context().lineTo(rect.width,rect.height);
+ this.context().lineTo(0,rect.height);
+ this.context().lineTo(0,0);
+
+ context.lineCap="round";
+ context.lineWidth = 1;
+ context.strokeStyle = "#ff0000";
+ context.stroke();
+ context.closePath();
+ }
+
+ this.context = function()
+ {
+ return this.element.getContext('2d');
+ }
+
+ this.clear = function()
+ {
+ this.context().clearRect(0, 0, canvas.width, canvas.height);
+ }
}
\ No newline at end of file
diff --git a/scripts/unit.command.js b/scripts/unit.command.js
new file mode 100644
index 0000000..8f582cf
--- /dev/null
+++ b/scripts/unit.command.js
@@ -0,0 +1,28 @@
+function Command(cmd_array)
+{
+ this.cmd_array = cmd_array;
+
+ this.rect = function()
+ {
+ for (i = 0; i < this.cmd_array.length; i++) {
+ if(this.cmd_array[i].indexOf("x") >= 0){ return new Rect(this.cmd_array[i]); }
+ }
+ return null;
+ }
+
+ this.position = function()
+ {
+ for (i = 0; i < this.cmd_array.length; i++) {
+ if(this.cmd_array[i].indexOf(",") >= 0){ return new Position(this.cmd_array[i]); }
+ }
+ return null;
+ }
+
+ this.color = function()
+ {
+ for (i = 0; i < this.cmd_array.length; i++) {
+ if(this.cmd_array[i].indexOf("#") >= 0){ return new Color(this.cmd_array[i]); }
+ }
+ return null;
+ }
+}
\ No newline at end of file