Progress with params in methods

This commit is contained in:
Devine Lu Linvega 2017-03-22 15:29:37 -07:00
parent 3f17f37458
commit 1bd42e15c8
6 changed files with 36 additions and 24 deletions

View File

@ -104,4 +104,12 @@ function Command(content)
}
return a;
}
this.method = function(name)
{
for(i in this.methods()){
var m = new Method(this.methods()[i]);
if(m.name == name){ return m; }
}
}
}

View File

@ -167,7 +167,7 @@ function Cursor(rune)
this.mouse_move = function(position)
{
if(!this.layer){ this.create_layer(); }
this.layer.clear();
this.position = ronin.magnet.update_mouse(position);

View File

@ -13,6 +13,11 @@ function Module(rune)
console.log("Installing "+ronin.modules[this.rune].constructor.name);
}
this.context = function()
{
return this.select_layer().context();
}
this.create_layer = function()
{
this.layer = new Layer(this.constructor.name+".Preview",this);

View File

@ -127,11 +127,6 @@ function Overlay(rune)
this.context().closePath();
}
this.clear = function()
{
this.context().clearRect(0, 0, ronin.surface.settings["size"].width, ronin.surface.settings["size"].height);
}
// Cursor
this.live_draw_from = null;

View File

@ -4,7 +4,7 @@ function Surface(rune)
this.element = null;
this.settings = {"size":new Rect("200x200")};
this.methods = [new Method("resize",[new Rect().name])]
this.methods = [new Method("resize",[new Rect().name]),new Method("crop",[new Position().name,new Rect().name])]
this.layers = {};
this.active_layer = null;
@ -130,11 +130,19 @@ function Surface(rune)
if(keys[loc-1] != null){this.select_layer(ronin.surface.layers[keys[loc-1]]);}
}
// Layers
this.passive = function(cmd)
{
var crop = ronin.terminal.cmd().method("crop");
this.context = function()
{
return this.active_layer.context();
if(crop && crop.params.length == 2){
console.log(crop);
ronin.overlay.select_layer().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
@ -146,19 +154,14 @@ function Surface(rune)
this.mouse_down = function(position)
{
ronin.overlay.clear();
ronin.overlay.select_layer().clear();
ronin.overlay.draw_pointer(position);
ronin.terminal.input_element.value = "| "+this.mouse_from.render();
}
this.mouse_move = function(position,rect)
{
ronin.overlay.clear();
ronin.overlay.draw_rect(this.mouse_from,rect);
ronin.terminal.input_element.value = "@ "+this.mouse_from.render()+" "+rect.render();
ronin.terminal.update_hint();
{
ronin.terminal.input_element.value = "@ crop:"+this.mouse_from.render()+":"+rect.render()+" ";
this.passive();
}
this.mouse_up = function(position,rect)

View File

@ -1,16 +1,17 @@
function Method(name,params)
function Method(method_str)
{
Unit.call(this);
this.name = name;
this.params = params;
var content = method_str.split(":");
this.name = content.shift();
this.params = content;
this.example = "";
this.render = function()
{
var s = name+":";
for(param in this.params){
s += this.params[param]+","
s += this.params[param]+":"
}
s = s.substr(0,s.length-1);