Implemented temporary storage.
This commit is contained in:
parent
5cc654cd6d
commit
99fce57b35
13
README.md
13
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)
|
||||
|
@ -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);
|
||||
|
@ -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(" "));
|
||||
|
@ -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)
|
||||
|
@ -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("<title>"+(cmd.cmd_array[0] ? cmd.cmd_array[0] : "Untitled")+"</title><img src='"+d+"' alt='from canvas'/>");
|
||||
if(cmd.value() > 0){
|
||||
this.storage[cmd.value()] = canvas.toDataURL("image/png");
|
||||
}
|
||||
else{
|
||||
var d=canvas.toDataURL("image/png");
|
||||
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'/>");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
function History(element)
|
||||
{
|
||||
Module.call(this);
|
||||
|
||||
this.element = element;
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
this.passive = function(cmd)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
function Ronin()
|
||||
{
|
||||
this.element = null;
|
||||
this.canvas = new Canvas();
|
||||
this.overlay = new Overlay();
|
||||
this.brush = new Brush();
|
||||
this.file = new File();
|
||||
this.hint = new Hint();
|
||||
this.element = null;
|
||||
this.canvas = new Canvas();
|
||||
this.overlay = new Overlay();
|
||||
this.brush = new Brush();
|
||||
this.file = new File();
|
||||
this.hint = new Hint();
|
||||
|
||||
this.fill = function(p)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user