diff --git a/README.md b/README.md index fa4c871..742df93 100644 --- a/README.md +++ b/README.md @@ -7,24 +7,17 @@ @ ? ; Clear canvas ``` -##History* -``` -~ ; Keep image progress -~ 3 ; Keep image progress into temporary memory with id 3 -~ ? ; Clear history -``` - ##Save File ``` -$ new_name.jpg ; Create a new file with name +$ new_name ; Create a new file with name +$ 3 ; Save to temporary storage, accessible with Load ``` ##Load File ``` / dir/file_name.jpg 10,10 100x100 ; Load image, at 10,10 with size 100x100 / dir/file_name.jpg 10,10 100x ; Load image, at 10,10 with size 100w and auto height -/ ~ ; Load last history id -/ 3 ; Load history id +/ 3 ; Load temporary storage id ``` ##Brush(Pointers) diff --git a/scripts/commander.js b/scripts/commander.js index dd2550a..55e1362 100644 --- a/scripts/commander.js +++ b/scripts/commander.js @@ -27,7 +27,7 @@ function Commander(element,element_input) ronin.canvas.active(cmd); break; case "~": // TODO - ronin.history.active(cmd); + ronin.memory.active(cmd); break; case "$": ronin.file.save(cmd); @@ -70,8 +70,8 @@ function Commander(element,element_input) ronin.module = ronin.canvas; break; case "~": - ronin.history.passive(this.cmd); - ronin.module = ronin.history; + ronin.memory.passive(this.cmd); + ronin.module = ronin.memory; break; case "/": ronin.file.passive(this.cmd); diff --git a/scripts/keyboard.js b/scripts/keyboard.js index 7801fee..1e1aaf7 100644 --- a/scripts/keyboard.js +++ b/scripts/keyboard.js @@ -51,24 +51,12 @@ function Keyboard() // Passive var cmd = commander.element_input.value; - - if(cmd.indexOf(";") > 0){ - var cmds = cmd.split(";"); - for (i = 0; i < cmds.length; i++) { - cmd = cmds[i].replace(/^\s+|\s+$/g, ''); - commander.passive(cmd.split(" ")); - } - } - else{ - commander.passive(cmd.split(" ")); - } - + commander.passive(cmd.split(" ")); ronin.hint.update(); }; this.key_tab = function() { - return; } this.key_enter = function() @@ -76,11 +64,11 @@ function Keyboard() var cmd = commander.element_input.value; if(cmd.indexOf(";") > 0){ - var cmds = cmd.split(";"); - for (i = 0; i < cmds.length; i++) { - cmd = cmds[i].replace(/^\s+|\s+$/g, ''); - commander.active(cmd.split(" ")); - } + var multi = cmd.split(";"); + if(multi[0]){commander.active(multi[0].split(" "));} + if(multi[1]){commander.active(multi[1].split(" "));} + if(multi[2]){commander.active(multi[2].split(" "));} + if(multi[3]){commander.active(multi[3].split(" "));} } else{ commander.active(cmd.split(" ")); diff --git a/scripts/ronin.brush.js b/scripts/ronin.brush.js index 85d38fe..3377c76 100644 --- a/scripts/ronin.brush.js +++ b/scripts/ronin.brush.js @@ -37,37 +37,6 @@ function Brush() return "Brush: "+hint_value+hint_position+hint_color; } - // Commander - - this.settings = function(p) - { - if(p[0]){ this.size = parseInt(p[0]); } - if(p[1]){ this.opacity = parseFloat(p[1]); } - if(p[2]){ this.color = new Color(p[2]); } - } - - this.add = function(p) - { - if(p.length >= 2){ - var position = new Position(parseInt(p[0]),parseInt(p[1])); - var pointer = new Pointer(position); - } - - if(p.length >= 4){ - var mirror = new Position(parseInt(p[2]),parseInt(p[3])); - pointer.mirror = mirror; - } - - this.add_pointer(pointer); - } - - this.remove = function(p) - { - this.remove_pointer(new Position(p[0],p[1])); - } - - // Pointers - this.pointers = [new Pointer(new Position())]; this.add_pointer = function(pointer) @@ -75,16 +44,6 @@ function Brush() this.pointers.push(pointer); } - this.remove_pointer = function(target_position) - { - for (i = 0; i < this.pointers.length; i++) { - if(this.pointers[i].offset.is_equal(target_position)){ - this.pointers.splice(i, 1); - break; - } - } - } - // Draw this.draw = function(e) diff --git a/scripts/ronin.file.js b/scripts/ronin.file.js index f1b3b13..6e5ff02 100644 --- a/scripts/ronin.file.js +++ b/scripts/ronin.file.js @@ -2,17 +2,20 @@ function File() { Module.call(this); + this.storage = []; + this.active = function(cmd) { ronin.overlay.clear(); if(!cmd.position()){ return; } if(!cmd.rect()){ return; } + if(!cmd.path() && !cmd.value()){ return; } var position = cmd.position() ? cmd.position() : new Position(); base_image = new Image(); - base_image.src = cmd.path(); + base_image.src = cmd.value() && this.storage[cmd.value()] ? this.storage[cmd.value()] : cmd.path(); base_image.onload = function(){ position.normalize(cmd.rect()); context.drawImage(base_image, position.x, position.y, cmd.rect().width, cmd.rect().height); @@ -21,7 +24,7 @@ function File() this.passive = function(cmd) { - if(!cmd.path()){ return; } + if(!cmd.path() && !cmd.value()){ return; } var position = cmd.position() ? cmd.position() : new Position(); @@ -44,8 +47,13 @@ function File() this.save = function(cmd) { - var d=canvas.toDataURL("image/png"); - var w=window.open('about:blank','image from canvas'); - w.document.write("