Implemented temporary storage.
This commit is contained in:
parent
5cc654cd6d
commit
99fce57b35
13
README.md
13
README.md
@ -7,24 +7,17 @@
|
|||||||
@ ? ; Clear canvas
|
@ ? ; Clear canvas
|
||||||
```
|
```
|
||||||
|
|
||||||
##History*
|
|
||||||
```
|
|
||||||
~ ; Keep image progress
|
|
||||||
~ 3 ; Keep image progress into temporary memory with id 3
|
|
||||||
~ ? ; Clear history
|
|
||||||
```
|
|
||||||
|
|
||||||
##Save File
|
##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
|
##Load File
|
||||||
```
|
```
|
||||||
/ dir/file_name.jpg 10,10 100x100 ; Load image, at 10,10 with size 100x100
|
/ 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
|
/ dir/file_name.jpg 10,10 100x ; Load image, at 10,10 with size 100w and auto height
|
||||||
/ ~ ; Load last history id
|
/ 3 ; Load temporary storage id
|
||||||
/ 3 ; Load history id
|
|
||||||
```
|
```
|
||||||
|
|
||||||
##Brush(Pointers)
|
##Brush(Pointers)
|
||||||
|
@ -27,7 +27,7 @@ function Commander(element,element_input)
|
|||||||
ronin.canvas.active(cmd);
|
ronin.canvas.active(cmd);
|
||||||
break;
|
break;
|
||||||
case "~": // TODO
|
case "~": // TODO
|
||||||
ronin.history.active(cmd);
|
ronin.memory.active(cmd);
|
||||||
break;
|
break;
|
||||||
case "$":
|
case "$":
|
||||||
ronin.file.save(cmd);
|
ronin.file.save(cmd);
|
||||||
@ -70,8 +70,8 @@ function Commander(element,element_input)
|
|||||||
ronin.module = ronin.canvas;
|
ronin.module = ronin.canvas;
|
||||||
break;
|
break;
|
||||||
case "~":
|
case "~":
|
||||||
ronin.history.passive(this.cmd);
|
ronin.memory.passive(this.cmd);
|
||||||
ronin.module = ronin.history;
|
ronin.module = ronin.memory;
|
||||||
break;
|
break;
|
||||||
case "/":
|
case "/":
|
||||||
ronin.file.passive(this.cmd);
|
ronin.file.passive(this.cmd);
|
||||||
|
@ -51,24 +51,12 @@ function Keyboard()
|
|||||||
|
|
||||||
// Passive
|
// Passive
|
||||||
var cmd = commander.element_input.value;
|
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(" "));
|
commander.passive(cmd.split(" "));
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
commander.passive(cmd.split(" "));
|
|
||||||
}
|
|
||||||
|
|
||||||
ronin.hint.update();
|
ronin.hint.update();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.key_tab = function()
|
this.key_tab = function()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.key_enter = function()
|
this.key_enter = function()
|
||||||
@ -76,11 +64,11 @@ function Keyboard()
|
|||||||
var cmd = commander.element_input.value;
|
var cmd = commander.element_input.value;
|
||||||
|
|
||||||
if(cmd.indexOf(";") > 0){
|
if(cmd.indexOf(";") > 0){
|
||||||
var cmds = cmd.split(";");
|
var multi = cmd.split(";");
|
||||||
for (i = 0; i < cmds.length; i++) {
|
if(multi[0]){commander.active(multi[0].split(" "));}
|
||||||
cmd = cmds[i].replace(/^\s+|\s+$/g, '');
|
if(multi[1]){commander.active(multi[1].split(" "));}
|
||||||
commander.active(cmd.split(" "));
|
if(multi[2]){commander.active(multi[2].split(" "));}
|
||||||
}
|
if(multi[3]){commander.active(multi[3].split(" "));}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
commander.active(cmd.split(" "));
|
commander.active(cmd.split(" "));
|
||||||
|
@ -37,37 +37,6 @@ function Brush()
|
|||||||
return "Brush: "+hint_value+hint_position+hint_color;
|
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.pointers = [new Pointer(new Position())];
|
||||||
|
|
||||||
this.add_pointer = function(pointer)
|
this.add_pointer = function(pointer)
|
||||||
@ -75,16 +44,6 @@ function Brush()
|
|||||||
this.pointers.push(pointer);
|
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
|
// Draw
|
||||||
|
|
||||||
this.draw = function(e)
|
this.draw = function(e)
|
||||||
|
@ -2,17 +2,20 @@ function File()
|
|||||||
{
|
{
|
||||||
Module.call(this);
|
Module.call(this);
|
||||||
|
|
||||||
|
this.storage = [];
|
||||||
|
|
||||||
this.active = function(cmd)
|
this.active = function(cmd)
|
||||||
{
|
{
|
||||||
ronin.overlay.clear();
|
ronin.overlay.clear();
|
||||||
|
|
||||||
if(!cmd.position()){ return; }
|
if(!cmd.position()){ return; }
|
||||||
if(!cmd.rect()){ return; }
|
if(!cmd.rect()){ return; }
|
||||||
|
if(!cmd.path() && !cmd.value()){ return; }
|
||||||
|
|
||||||
var position = cmd.position() ? cmd.position() : new Position();
|
var position = cmd.position() ? cmd.position() : new Position();
|
||||||
|
|
||||||
base_image = new Image();
|
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(){
|
base_image.onload = function(){
|
||||||
position.normalize(cmd.rect());
|
position.normalize(cmd.rect());
|
||||||
context.drawImage(base_image, position.x, position.y, cmd.rect().width, cmd.rect().height);
|
context.drawImage(base_image, position.x, position.y, cmd.rect().width, cmd.rect().height);
|
||||||
@ -21,7 +24,7 @@ function File()
|
|||||||
|
|
||||||
this.passive = function(cmd)
|
this.passive = function(cmd)
|
||||||
{
|
{
|
||||||
if(!cmd.path()){ return; }
|
if(!cmd.path() && !cmd.value()){ return; }
|
||||||
|
|
||||||
var position = cmd.position() ? cmd.position() : new Position();
|
var position = cmd.position() ? cmd.position() : new Position();
|
||||||
|
|
||||||
@ -44,8 +47,13 @@ function File()
|
|||||||
|
|
||||||
this.save = function(cmd)
|
this.save = function(cmd)
|
||||||
{
|
{
|
||||||
|
if(cmd.value() > 0){
|
||||||
|
this.storage[cmd.value()] = canvas.toDataURL("image/png");
|
||||||
|
}
|
||||||
|
else{
|
||||||
var d=canvas.toDataURL("image/png");
|
var d=canvas.toDataURL("image/png");
|
||||||
var w=window.open('about:blank','image from canvas');
|
var w=window.open('about:blank','image from canvas');
|
||||||
w.document.write("<title>"+(cmd.cmd_array[0] ? cmd.cmd_array[0] : "Untitled")+"</title><img src='"+d+"' alt='from canvas'/>");
|
w.document.write("<title>"+(cmd.cmd_array[0] ? cmd.cmd_array[0] : "Untitled")+"</title><img src='"+d+"' alt='from canvas'/>");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,16 +0,0 @@
|
|||||||
function History(element)
|
|
||||||
{
|
|
||||||
Module.call(this);
|
|
||||||
|
|
||||||
this.element = element;
|
|
||||||
|
|
||||||
this.active = function(cmd)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.passive = function(cmd)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user