Added history to the commander.

This commit is contained in:
Devine Lu Linvega 2016-11-16 11:36:11 -08:00
parent 747ecc24c6
commit cce5a57fd0
5 changed files with 30 additions and 18 deletions

View File

@ -41,10 +41,10 @@ $ ! ; Clear temporary storage
| ! ; Remove all guides | ! ; Remove all guides
``` ```
##Vector(SVG Path) ##Vector(SVG)
``` ```
+ M10 10 h 80 v 80 h -80 Z ; Draw a square outline + M10 10 h 80 v 80 h -80 Z ; Draw a square outline
+ M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80 ; Draw a bezier + M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80 ; Draw a bezier
+ M 100, 100 m -75, 0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0 ; Draw a circle + M 100, 100 m -75, 0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0 ; Draw a circle
``` ```
@ -74,13 +74,7 @@ $ ! ; Clear temporary storage
= ! ; Zoom 100% = ! ; Zoom 100%
``` ```
##Layers* #Units
```
# 3 ; Layer 3
# ! ; Layer 1
```
#Units*
``` ```
5 ; value: 5 5 ; value: 5
5,7 ; position: 5x 7y 5,7 ; position: 5x 7y

View File

@ -4,6 +4,7 @@ function Commander(element,element_input)
this.element_input = element_input; this.element_input = element_input;
this.cmd = null; this.cmd = null;
this.storage = []; this.storage = [];
this.storage_index = 0;
this.show = function() this.show = function()
{ {
@ -17,8 +18,28 @@ function Commander(element,element_input)
this.element_input.value = ""; this.element_input.value = "";
} }
this.clear = function()
{
this.element_input.value = "";
}
this.next_cmd = function()
{
this.storage_index += this.storage_index < this.storage.length ? 1 : 0;
this.element_input.value = this.storage[this.storage_index] ? this.storage[this.storage_index] : "";
}
this.prev_cmd = function()
{
this.storage_index -= this.storage_index < 1 ? 0 : 1;
this.element_input.value = this.storage[this.storage_index];
}
this.active = function(content) this.active = function(content)
{ {
this.storage.push(content.join(" "));
this.storage_index = this.storage.length;
var key = content[0]; var key = content[0];
content.shift(); content.shift();
var cmd = new Command(content); var cmd = new Command(content);
@ -58,7 +79,6 @@ function Commander(element,element_input)
ronin.vector.active(cmd); ronin.vector.active(cmd);
break; break;
} }
this.storage.push(content);
this.hide(); this.hide();
} }

View File

@ -85,10 +85,12 @@ function Keyboard()
this.key_arrow_up = function() this.key_arrow_up = function()
{ {
commander.prev_cmd();
} }
this.key_arrow_down = function() this.key_arrow_down = function()
{ {
commander.next_cmd();
} }
this.key_arrow_left = function() this.key_arrow_left = function()

View File

@ -13,7 +13,5 @@ function Hint(element)
else{ else{
this.element.style.display = "none"; this.element.style.display = "none";
} }
console.log(ronin.module);
} }
} }

View File

@ -10,18 +10,16 @@ function Vector()
this.active = function(cmd) this.active = function(cmd)
{ {
var path = new Path2D(cmd.content.join(" "));
console.log(ronin.size);
ronin.canvas.context().lineCap="round"; ronin.canvas.context().lineCap="round";
ronin.canvas.context().lineWidth = ronin.brush.size; ronin.canvas.context().lineWidth = ronin.brush.size;
ronin.canvas.context().strokeStyle = ronin.brush.color.rgba(); ronin.canvas.context().strokeStyle = ronin.brush.color.rgba();
ronin.canvas.context().stroke(path); ronin.canvas.context().stroke(Path2D(cmd.content.join(" ")));
} }
this.hint = function(cmd) this.hint = function(cmd)
{ {
return "Vector: " return "Vector: "
} }
// M100,100 h200 a20,20 0 0 1 20,20 v200 a20,20 0 0 1 -20,20 h-200 a20,20 0 0 1 -20,-20 v-200 a20,20 0 0 1 20,-20 z
} }