New paradigm, GO!
This commit is contained in:
parent
061b832851
commit
8d7c25c489
@ -37,6 +37,8 @@ Enjoy
|
||||
Load default.rin on startup
|
||||
* Eye
|
||||
Swatches, handle all colors
|
||||
+ Path
|
||||
Rename vector to Path
|
||||
|
||||
|
||||
this.collection = {};
|
||||
|
@ -2,6 +2,11 @@ function Default(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.hint = function()
|
||||
{
|
||||
return "??";
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
this.mouse_mode = function()
|
||||
|
@ -15,7 +15,7 @@ function Module(rune)
|
||||
|
||||
this.context = function()
|
||||
{
|
||||
return this._layer().context();
|
||||
return this.get_layer().context();
|
||||
}
|
||||
|
||||
this.create_layer = function()
|
||||
@ -25,9 +25,9 @@ function Module(rune)
|
||||
ronin.surface.add_layer(this.layer);
|
||||
}
|
||||
|
||||
this._layer = function()
|
||||
this.get_layer = function(is_blinking = false)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
if(!this.layer){ this.create_layer(); this.layer.is_blinking = is_blinking }
|
||||
return this.layer;
|
||||
}
|
||||
|
||||
@ -67,21 +67,28 @@ function Module(rune)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.add_method = function(method)
|
||||
{
|
||||
this.methods[method.name] = method;
|
||||
}
|
||||
|
||||
this.hint = function(content)
|
||||
{
|
||||
var h = "<b>"+ronin.module.constructor.name+"</b> ";
|
||||
|
||||
for(method in ronin.module.methods){
|
||||
h += ronin.module.methods[method].render()+" ";
|
||||
}
|
||||
for(setting in ronin.module.settings){
|
||||
h += setting+"="+ronin.module.settings[setting].render()+" ";
|
||||
}
|
||||
var s = "";
|
||||
|
||||
h += ronin.module.mouse_mode() ? "<i>"+ronin.module.mouse_mode()+"</i>" : "";
|
||||
var method_name = content.split(" ")[0];
|
||||
|
||||
return this.pad(content)+h;
|
||||
if(this.methods[method_name]){
|
||||
console.log(this.methods[method_name].params)
|
||||
s = this.methods[method_name].params;
|
||||
}
|
||||
else{
|
||||
for(method in this.methods){
|
||||
s += "."+method+"("+method_name+") ";
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
this.pad = function(input)
|
||||
|
@ -4,12 +4,14 @@ function Surface(rune)
|
||||
|
||||
this.element = null;
|
||||
this.settings = {"size":new Rect("200x200")};
|
||||
this.methods = [new Method("resize",[new Rect().name]),new Method("crop",[new Position().name,new Rect().name])]
|
||||
|
||||
this.layers = {};
|
||||
this.active_layer = null;
|
||||
this.render_layer = null;
|
||||
|
||||
this.add_method(new Method("resize",[new Rect().name]));
|
||||
this.add_method(new Method("crop",[new Position().name,new Rect().name]));
|
||||
|
||||
this.widget_element = document.createElement("widget");
|
||||
|
||||
this.install = function()
|
||||
@ -18,13 +20,7 @@ function Surface(rune)
|
||||
this.blink();
|
||||
}
|
||||
|
||||
this.blink = function()
|
||||
{
|
||||
Object.keys(ronin.surface.layers).forEach(function (key) {
|
||||
ronin.surface.layers[key].blink();
|
||||
});
|
||||
setTimeout(function(){ ronin.surface.blink(); }, 30);
|
||||
}
|
||||
// Methods
|
||||
|
||||
this.resize = function(params)
|
||||
{
|
||||
@ -46,6 +42,11 @@ function Surface(rune)
|
||||
ronin.terminal.log(new Log(this,"Resized Surface to "+this.settings["size"].render()));
|
||||
}
|
||||
|
||||
this.crop = function(params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
this.select = function(params)
|
||||
{
|
||||
var layer_name = params[0];
|
||||
@ -55,6 +56,16 @@ function Surface(rune)
|
||||
this.select_layer(this.layers[layer_name]);
|
||||
}
|
||||
|
||||
// Misc
|
||||
|
||||
this.blink = function()
|
||||
{
|
||||
Object.keys(ronin.surface.layers).forEach(function (key) {
|
||||
ronin.surface.layers[key].blink();
|
||||
});
|
||||
setTimeout(function(){ ronin.surface.blink(); }, 30);
|
||||
}
|
||||
|
||||
this.select_layer = function(layer)
|
||||
{
|
||||
console.log("Selecting layer:"+layer.name);
|
||||
@ -98,14 +109,14 @@ function Surface(rune)
|
||||
s += "<span class='cursor'>"+ronin.cursor.mode.mouse_mode()+"</span>";
|
||||
|
||||
var keys = Object.keys(ronin.surface.layers);
|
||||
// var loc = keys.indexOf(this.active_layer.name);
|
||||
var loc = keys.indexOf(this.active_layer.name);
|
||||
|
||||
// if(keys.length > 1){
|
||||
// s += "<span class='layer'>"+ronin.surface.active_layer.widget()+"("+(loc+1)+"/"+keys.length+")</span>";
|
||||
// }
|
||||
// else{
|
||||
// s += "<span class='layer'>"+ronin.surface.active_layer.widget()+"</span>";
|
||||
// }
|
||||
if(keys.length > 1){
|
||||
s += "<span class='layer'>"+ronin.surface.active_layer.widget()+"("+(loc+1)+"/"+keys.length+")</span>";
|
||||
}
|
||||
else{
|
||||
s += "<span class='layer'>"+ronin.surface.active_layer.widget()+"</span>";
|
||||
}
|
||||
|
||||
this.widget_element.innerHTML = s;
|
||||
}
|
||||
@ -136,7 +147,7 @@ function Surface(rune)
|
||||
|
||||
if(crop && crop.params.length == 2){
|
||||
console.log(crop);
|
||||
ronin.overlay.select_layer().clear();
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
ronin.overlay.draw_rect(new Position(crop.params[0]),new Rect(crop.params[1]));
|
||||
}
|
||||
else{
|
||||
@ -154,7 +165,7 @@ function Surface(rune)
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
ronin.overlay.select_layer().clear();
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
ronin.overlay.draw_pointer(position);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,10 @@ function Terminal(rune)
|
||||
|
||||
this.passive = function(content)
|
||||
{
|
||||
this.hint(content);
|
||||
|
||||
|
||||
return;
|
||||
var key = content[0];
|
||||
var cmd = this.cmd();
|
||||
|
||||
@ -85,6 +89,16 @@ function Terminal(rune)
|
||||
|
||||
function active(content)
|
||||
{
|
||||
var module_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[0] : content.split(" ")[0];
|
||||
var method_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[1] : "default";
|
||||
|
||||
if(ronin[module_name] && ronin[module_name][method_name]){
|
||||
ronin[module_name][method_name]();
|
||||
}
|
||||
else{
|
||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown module"));
|
||||
}
|
||||
|
||||
var key = content[0];
|
||||
var cmd = new Command(content.substring(1).trim().split(" "));
|
||||
|
||||
@ -105,22 +119,13 @@ function Terminal(rune)
|
||||
|
||||
this.update_hint = function(content = this.input_element.value)
|
||||
{
|
||||
// ronin.terminal.input_element.setAttribute("style","color:"+ronin.brush.color.hex);
|
||||
var module_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[0] : content.split(" ")[0];
|
||||
|
||||
if(content.indexOf(";") > -1){
|
||||
this.hint_element.innerHTML = this.pad(content)+" "+content.split(";").length+" commands";
|
||||
if(ronin[module_name]){
|
||||
this.hint_element.innerHTML = this.pad(content)+ronin[module_name].hint(content.replace(module_name+".",""));
|
||||
}
|
||||
else if(ronin.module){
|
||||
this.hint_element.innerHTML = ronin.module.hint(content);
|
||||
}
|
||||
else if(content == ""){
|
||||
this.hint_element.innerHTML = "";
|
||||
for(module in ronin.modules){
|
||||
this.hint_element.innerHTML += "<b>"+module+"</b> "+ronin.modules[module].constructor.name+" ";
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.hint_element.innerHTML = this.pad(content)+" Unknown Command."
|
||||
this.hint_element.innerHTML = this.pad(content)+ronin["default"].hint(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,23 @@ function Vector(rune)
|
||||
this.parameters = [Any];
|
||||
this.variables = {"fill_color" : null,"stroke_width" : 5,"stroke_color" : "#ffffff", "line_cap" : "square"};
|
||||
|
||||
this.add_method(new Method("stroke",["Positions"]));
|
||||
this.add_method(new Method("fill",["Positions"]));
|
||||
|
||||
this.coordinates = [];
|
||||
this.last_pos = null;
|
||||
this.paths = [];
|
||||
|
||||
this.stroke = function()
|
||||
{
|
||||
// TODO
|
||||
console.warn("!!!!!")
|
||||
}
|
||||
|
||||
this.fill = function()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Module
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
function Method(method_str)
|
||||
function Method(name,params)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
var content = method_str.split(":");
|
||||
this.name = content.shift();
|
||||
this.params = content;
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
this.example = "";
|
||||
|
||||
this.render = function()
|
||||
|
Loading…
x
Reference in New Issue
Block a user