Improved surface
This commit is contained in:
parent
bdb80e5a7d
commit
3844a79de9
@ -32,11 +32,11 @@ starting_canvas.width = parseInt(starting_canvas.width/40) * 40;
|
||||
starting_canvas.height = parseInt(starting_canvas.height/40) * 40;
|
||||
|
||||
ronin.terminal.query("~ "+ronin.timestamp());
|
||||
ronin.terminal.query("surface.select main");
|
||||
ronin.terminal.query("surface.resize "+starting_canvas.render());
|
||||
ronin.terminal.query("@ select:Main");
|
||||
ronin.terminal.query("- color=#ff0000");
|
||||
ronin.terminal.query("# fill=#ff0000");
|
||||
ronin.terminal.query("~ Ready.");
|
||||
// ronin.terminal.query("- color=#ff0000");
|
||||
// ronin.terminal.query("# fill=#ff0000");
|
||||
// ronin.terminal.query("~ Ready.");
|
||||
|
||||
ronin.terminal.input_element.focus();
|
||||
ronin.terminal.update_hint();
|
||||
|
@ -20,7 +20,7 @@ function Path(rune)
|
||||
this.layer.context().lineCap = this.settings["line_cap"];
|
||||
this.layer.context().lineWidth = this.settings["line_width"];
|
||||
this.layer.context().strokeStyle = this.settings["line_color"];
|
||||
ronin.path.layer.context().stroke(new Path2D(params));
|
||||
ronin.path.layer.context().stroke(new Path2D(params.content));
|
||||
}
|
||||
|
||||
this.fill = function(params,preview = false)
|
||||
@ -30,7 +30,7 @@ function Path(rune)
|
||||
this.layer.clear();
|
||||
this.layer.context().fillStyle = this.settings["fill_color"];
|
||||
|
||||
ronin.path.layer.context().fill(new Path2D(params));
|
||||
ronin.path.layer.context().fill(new Path2D(params.content));
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
@ -22,13 +22,15 @@ function Surface(rune)
|
||||
|
||||
// Methods
|
||||
|
||||
this.resize = function(params)
|
||||
this.resize = function(params, preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
this.settings["size"] = params.rect();
|
||||
|
||||
Object.keys(ronin.surface.layers).forEach(function (key) {
|
||||
ronin.surface.layers[key].resize(this.settings["size"]);
|
||||
});
|
||||
for(layer_name in ronin.surface.layers){
|
||||
ronin.surface.layers[layer_name].resize(this.settings["size"]);
|
||||
}
|
||||
|
||||
ronin.surface.element.width = this.settings["size"].width * 2;
|
||||
ronin.surface.element.height = this.settings["size"].height * 2;
|
||||
@ -41,14 +43,19 @@ function Surface(rune)
|
||||
ronin.terminal.log(new Log(this,"Resized Surface to "+this.settings["size"].render()));
|
||||
}
|
||||
|
||||
this.crop = function(params)
|
||||
this.crop = function(params, preview = false)
|
||||
{
|
||||
if(!params.position() || !params.rect()){ return; }
|
||||
|
||||
this.settings["size"] = params.rect();
|
||||
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
ronin.overlay.draw_rect(params.position(),params.rect());
|
||||
}
|
||||
|
||||
this.select = function(params)
|
||||
{
|
||||
var layer_name = params[0];
|
||||
var layer_name = params.content;
|
||||
if(!ronin.surface.layers[layer_name]){
|
||||
this.add_layer(new Layer(layer_name));
|
||||
}
|
||||
@ -67,7 +74,6 @@ function Surface(rune)
|
||||
|
||||
this.select_layer = function(layer)
|
||||
{
|
||||
console.log("Selecting layer:"+layer.name);
|
||||
this.active_layer = layer;
|
||||
}
|
||||
|
||||
@ -142,20 +148,20 @@ function Surface(rune)
|
||||
if(keys[loc-1] != null){this.select_layer(ronin.surface.layers[keys[loc-1]]);}
|
||||
}
|
||||
|
||||
this.passive = function(cmd)
|
||||
{
|
||||
var crop = ronin.terminal.cmd().method("crop");
|
||||
// this.passive = function(cmd)
|
||||
// {
|
||||
// var crop = ronin.terminal.cmd().method("crop");
|
||||
|
||||
if(crop && crop.params.length == 2){
|
||||
console.log(crop);
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
ronin.overlay.draw_rect(new Position(crop.params[0]),new Rect(crop.params[1]));
|
||||
}
|
||||
else{
|
||||
console.log("Missing params")
|
||||
}
|
||||
ronin.terminal.update_hint();
|
||||
}
|
||||
// if(crop && crop.params.length == 2){
|
||||
// console.log(crop);
|
||||
// ronin.overlay.get_layer(true).clear();
|
||||
// ronin.overlay.draw_rect(new Position(crop.params[0]),new Rect(crop.params[1]));
|
||||
// }
|
||||
// else{
|
||||
// console.log("Missing params")
|
||||
// }
|
||||
// ronin.terminal.update_hint();
|
||||
// }
|
||||
|
||||
// Cursor
|
||||
|
||||
@ -172,8 +178,8 @@ function Surface(rune)
|
||||
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
ronin.terminal.input_element.value = "@ crop:"+this.mouse_from.render()+":"+rect.render()+" ";
|
||||
this.passive();
|
||||
ronin.terminal.input_element.value = "surface."+ronin.terminal.method_name+" "+this.mouse_from.render()+" "+rect.render()+" ";
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
this.mouse_up = function(position,rect)
|
||||
|
@ -26,33 +26,6 @@ function Terminal(rune)
|
||||
this.active = function(cmd)
|
||||
{
|
||||
}
|
||||
|
||||
this.module_name = null;
|
||||
this.method_name = null;
|
||||
this.method_params = null;
|
||||
|
||||
this.passive = function()
|
||||
{
|
||||
var content = this.input_element.value;
|
||||
var parts = content.split(" ");
|
||||
var key = parts.shift();
|
||||
|
||||
this.module_name = key.split(".")[0];
|
||||
this.method_name = key.indexOf(".") > -1 ? key.split(".")[1] : null;
|
||||
this.method_params = parts;
|
||||
|
||||
if(ronin[this.module_name]){
|
||||
ronin.cursor.set_mode(ronin[this.module_name]);
|
||||
if(ronin[this.module_name][this.method_name]){
|
||||
ronin[this.module_name][this.method_name](this.method_params,true);
|
||||
}
|
||||
}
|
||||
else{
|
||||
ronin.cursor.set_mode(ronin.brush);
|
||||
}
|
||||
|
||||
this.hint(content);
|
||||
}
|
||||
|
||||
this.cmd = function()
|
||||
{
|
||||
@ -121,6 +94,33 @@ function Terminal(rune)
|
||||
// ronin.terminal.log(new Log(ronin.terminal,"Unknown module: "+key));
|
||||
// }
|
||||
}
|
||||
|
||||
this.module_name = null;
|
||||
this.method_name = null;
|
||||
this.method_params = null;
|
||||
|
||||
this.passive = function()
|
||||
{
|
||||
var content = this.input_element.value;
|
||||
var parts = content.split(" ");
|
||||
var key = parts.shift();
|
||||
|
||||
this.module_name = key.split(".")[0];
|
||||
this.method_name = key.indexOf(".") > -1 ? key.split(".")[1] : null;
|
||||
this.method_params = new Command(parts);
|
||||
|
||||
if(ronin[this.module_name]){
|
||||
ronin.cursor.set_mode(ronin[this.module_name]);
|
||||
if(ronin[this.module_name][this.method_name]){
|
||||
ronin[this.module_name][this.method_name](this.method_params,true);
|
||||
}
|
||||
}
|
||||
else{
|
||||
ronin.cursor.set_mode(ronin.brush);
|
||||
}
|
||||
|
||||
this.hint(content);
|
||||
}
|
||||
|
||||
// Hint
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user