Added feedback to Source()
This commit is contained in:
parent
a0e557d243
commit
0ac1986b42
@ -20,4 +20,5 @@ body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_medium"
|
|||||||
#terminal logs log { display: block; font-size:10px; line-height:25px; padding:0px 5px; color:#666;}
|
#terminal logs log { display: block; font-size:10px; line-height:25px; padding:0px 5px; color:#666;}
|
||||||
#terminal logs log .rune { color:white; }
|
#terminal logs log .rune { color:white; }
|
||||||
#terminal logs log.error .rune { color:red; }
|
#terminal logs log.error .rune { color:red; }
|
||||||
|
#terminal logs log.input { color:white; }
|
||||||
#terminal menu { display: inline-block;position: absolute;bottom: 0px;right: 0px;padding: 0px 5px;font-size: 10px;line-height: 20px;color:white }
|
#terminal menu { display: inline-block;position: absolute;bottom: 0px;right: 0px;padding: 0px 5px;font-size: 10px;line-height: 20px;color:white }
|
@ -34,9 +34,7 @@ starting_canvas.height = parseInt(starting_canvas.height/40) * 40;
|
|||||||
ronin.terminal.query("~ "+ronin.timestamp());
|
ronin.terminal.query("~ "+ronin.timestamp());
|
||||||
ronin.terminal.query("frame.select main");
|
ronin.terminal.query("frame.select main");
|
||||||
ronin.terminal.query("frame.resize "+starting_canvas.render());
|
ronin.terminal.query("frame.resize "+starting_canvas.render());
|
||||||
// ronin.terminal.query("- color=#ff0000");
|
ronin.terminal.query("brush:color #ff0000");
|
||||||
// ronin.terminal.query("# fill=#ff0000");
|
|
||||||
// ronin.terminal.query("~ Ready.");
|
|
||||||
|
|
||||||
ronin.terminal.input_element.focus();
|
ronin.terminal.input_element.focus();
|
||||||
ronin.terminal.update_hint();
|
ronin.terminal.update_hint();
|
||||||
|
@ -32,7 +32,7 @@ function Ronin()
|
|||||||
// this.modules[this.magnet.constructor.name] = this.magnet;
|
// this.modules[this.magnet.constructor.name] = this.magnet;
|
||||||
|
|
||||||
this.modules[this.cursor.constructor.name] = this.cursor;
|
this.modules[this.cursor.constructor.name] = this.cursor;
|
||||||
this.modules[this.terminal.constructor.name] = this.terminal;
|
// this.modules[this.terminal.constructor.name] = this.terminal;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -41,6 +41,8 @@ function Ronin()
|
|||||||
for(var key in this.modules){
|
for(var key in this.modules){
|
||||||
this.modules[key].install();
|
this.modules[key].install();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.terminal.install();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cursors = [];
|
this.cursors = [];
|
||||||
|
@ -4,19 +4,20 @@ function Brush(rune)
|
|||||||
|
|
||||||
// this.parameters = {"offset":Position,"mirror":Rect,"angle":Angle,"reset":Bang};
|
// this.parameters = {"offset":Position,"mirror":Rect,"angle":Angle,"reset":Bang};
|
||||||
this.parameters = [];
|
this.parameters = [];
|
||||||
this.settings = {"color":new Color("#ff0000"),"size":new Value(1)};
|
this.settings = {"color":"#ff0000","size":1};
|
||||||
this.pointers = [];
|
this.pointers = [new Pointer(new Position("0,0"))];
|
||||||
|
|
||||||
// Module
|
this.add_method(new Method("add_pointer",["Position"]));
|
||||||
|
|
||||||
this.install = function()
|
this.add_pointer = function(params, preview = false)
|
||||||
{
|
{
|
||||||
this.add_pointer(new Position("0,0"));
|
if(preview){ return; }
|
||||||
}
|
|
||||||
|
|
||||||
this.active = function(cmd)
|
var pointer = new Pointer();
|
||||||
{
|
pointer.offset = params.position() ? params.position() : new Position("0,0");
|
||||||
if(cmd.bang()){ this.pointers = []; }
|
this.pointers.push(pointer);
|
||||||
|
|
||||||
|
ronin.terminal.log(new Log(this,"Added pointer at: "+pointer.offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.passive = function(cmd)
|
this.passive = function(cmd)
|
||||||
@ -34,24 +35,16 @@ function Brush(rune)
|
|||||||
|
|
||||||
this.size_up = function()
|
this.size_up = function()
|
||||||
{
|
{
|
||||||
this.settings["size"].float -= this.settings["size"].float > 1 ? 1 : 0;
|
this.settings["size"] -= this.settings["size"] > 1 ? 1 : 0;
|
||||||
ronin.frame.update_widget();
|
ronin.frame.update_widget();
|
||||||
ronin.terminal.log(new Log(this,"Increased pointer size to: "+this.size));
|
ronin.terminal.log(new Log(this,"Increased pointer size to: "+this.settings["size"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.size_down = function()
|
this.size_down = function()
|
||||||
{
|
{
|
||||||
this.settings["size"].float += 1;
|
this.settings["size"] += 1;
|
||||||
ronin.frame.update_widget();
|
ronin.frame.update_widget();
|
||||||
ronin.terminal.log(new Log(this,"Decreased pointer size to: "+this.size));
|
ronin.terminal.log(new Log(this,"Decreased pointer size to: "+this.settings["size"]));
|
||||||
}
|
|
||||||
|
|
||||||
this.add_pointer = function(position)
|
|
||||||
{
|
|
||||||
ronin.terminal.log(new Log(this,"Added pointer at: "+position.render()));
|
|
||||||
var pointer = new Pointer();
|
|
||||||
pointer.offset = position;
|
|
||||||
this.pointers.push(pointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eraser
|
// Eraser
|
||||||
@ -67,7 +60,7 @@ function Brush(rune)
|
|||||||
ronin.frame.context().moveTo(this.position_prev.x,this.position_prev.y);
|
ronin.frame.context().moveTo(this.position_prev.x,this.position_prev.y);
|
||||||
ronin.frame.context().lineTo(position.x,position.y);
|
ronin.frame.context().lineTo(position.x,position.y);
|
||||||
ronin.frame.context().lineCap="round";
|
ronin.frame.context().lineCap="round";
|
||||||
ronin.frame.context().lineWidth = this.settings["size"].float * 5;
|
ronin.frame.context().lineWidth = this.settings["size"] * 5;
|
||||||
ronin.frame.context().strokeStyle = new Color("#ff0000").rgba();
|
ronin.frame.context().strokeStyle = new Color("#ff0000").rgba();
|
||||||
ronin.frame.context().stroke();
|
ronin.frame.context().stroke();
|
||||||
ronin.frame.context().closePath();
|
ronin.frame.context().closePath();
|
||||||
@ -79,16 +72,16 @@ function Brush(rune)
|
|||||||
|
|
||||||
this.mouse_pointer = function(position)
|
this.mouse_pointer = function(position)
|
||||||
{
|
{
|
||||||
return ronin.cursor.draw_pointer_circle(position,this.settings["size"].float);
|
return ronin.cursor.draw_pointer_circle(position,this.settings["size"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mouse_mode = function()
|
this.mouse_mode = function()
|
||||||
{
|
{
|
||||||
if(keyboard.shift_held == true){
|
if(keyboard.shift_held == true){
|
||||||
return "Eraser "+this.settings["size"].float;
|
return "Eraser "+this.settings["size"];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return "<i style='color:"+this.settings["color"].hex+"'>●</i> Brush "+ronin.brush.pointers.length+"x "+this.settings["size"].render();
|
return "<i style='color:"+this.settings["color"]+"'>●</i> Brush "+ronin.brush.pointers.length+"x "+this.settings["size"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
|||||||
|
|
||||||
ronin.frame.context().lineCap="round";
|
ronin.frame.context().lineCap="round";
|
||||||
ronin.frame.context().lineWidth = this.thickness();
|
ronin.frame.context().lineWidth = this.thickness();
|
||||||
ronin.frame.context().strokeStyle = ronin.brush.settings["color"].rgba();
|
ronin.frame.context().strokeStyle = new Color(ronin.brush.settings["color"]).rgba();
|
||||||
ronin.frame.context().stroke();
|
ronin.frame.context().stroke();
|
||||||
ronin.frame.context().closePath();
|
ronin.frame.context().closePath();
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ function Frame(rune)
|
|||||||
this.settings["size"] = params.rect();
|
this.settings["size"] = params.rect();
|
||||||
|
|
||||||
ronin.overlay.get_layer(true).clear();
|
ronin.overlay.get_layer(true).clear();
|
||||||
ronin.overlay.draw_rect(params.position(),params.rect());
|
if(preview){ronin.overlay.draw_rect(params.position(),params.rect());}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.select = function(params)
|
this.select = function(params)
|
||||||
|
@ -39,16 +39,10 @@ function Module(rune)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update_settings = function(cmd)
|
this.update_setting = function(name,value)
|
||||||
{
|
{
|
||||||
for (var key in this.settings){
|
this.settings[name] = value.content.join(" ");
|
||||||
if(!cmd.setting(key)){ continue; }
|
ronin.terminal.log(new Log(this,"Updated setting: "+name));
|
||||||
var value = new this.settings[key].constructor(cmd.setting(key).value);
|
|
||||||
this.settings[key] = value;
|
|
||||||
ronin.terminal.log(new Log(this,"Updated "+key+" with "+cmd.setting(key).value));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ronin.terminal.log(new Log(this,"Unknown setting: "+key));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.add_method = function(method)
|
this.add_method = function(method)
|
||||||
|
@ -11,12 +11,14 @@ function Source(rune)
|
|||||||
{
|
{
|
||||||
if(!params.filepath() || !params.rect() || !params.position()){ ronin.terminal.log(new Log(this,"Missing image path.","error")); return; }
|
if(!params.filepath() || !params.rect() || !params.position()){ ronin.terminal.log(new Log(this,"Missing image path.","error")); return; }
|
||||||
|
|
||||||
console.log("OK");
|
this.get_layer(true).clear();
|
||||||
|
|
||||||
|
var target_layer = preview ? this.get_layer(true) : ronin.frame.active_layer;
|
||||||
|
|
||||||
ronin.overlay.get_layer(true).clear();
|
ronin.overlay.get_layer(true).clear();
|
||||||
ronin.overlay.draw_rect(params.position(),params.rect());
|
|
||||||
|
|
||||||
var position = params.position() ? params.position() : new Position();
|
var position = params.position() ? params.position() : new Position();
|
||||||
|
ronin.overlay.draw_rect(params.position(),params.rect());
|
||||||
|
|
||||||
base_image = new Image();
|
base_image = new Image();
|
||||||
base_image.src = params.filepath().path;
|
base_image.src = params.filepath().path;
|
||||||
@ -35,8 +37,10 @@ function Source(rune)
|
|||||||
width = isNaN(width) && height > 0 ? (height*base_image.naturalWidth)/base_image.naturalHeight : width;
|
width = isNaN(width) && height > 0 ? (height*base_image.naturalWidth)/base_image.naturalHeight : width;
|
||||||
height = isNaN(height) && width > 0 ? (width*base_image.naturalHeight)/base_image.naturalWidth : height;
|
height = isNaN(height) && width > 0 ? (width*base_image.naturalHeight)/base_image.naturalWidth : height;
|
||||||
|
|
||||||
ronin.frame.context().drawImage(base_image, position.x, position.y, width, height);
|
target_layer.context().drawImage(base_image, position.x, position.y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!preview){ ronin.overlay.get_layer(true).clear(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
this.save = function(params,preview = false)
|
this.save = function(params,preview = false)
|
||||||
@ -80,4 +84,14 @@ function Source(rune)
|
|||||||
}
|
}
|
||||||
return this.layer;
|
return this.layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.key_escape = function()
|
||||||
|
{
|
||||||
|
if(this.layer){ this.layer.remove(this); }
|
||||||
|
this.coordinates = [];
|
||||||
|
this.last_pos = null;
|
||||||
|
ronin.terminal.input_element.value = "";
|
||||||
|
ronin.terminal.passive();
|
||||||
|
ronin.overlay.get_layer(true).clear();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
function Terminal(rune)
|
function Terminal(rune)
|
||||||
{
|
{
|
||||||
Module.call(this,rune);
|
Module.call(this,">");
|
||||||
|
|
||||||
this.element = null;
|
this.element = null;
|
||||||
this.input_element = document.createElement("input");
|
this.input_element = document.createElement("input");
|
||||||
@ -66,8 +66,20 @@ function Terminal(rune)
|
|||||||
|
|
||||||
function active(content)
|
function active(content)
|
||||||
{
|
{
|
||||||
var module_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[0] : content.split(" ")[0];
|
ronin.terminal.log(new Log(this,content,"input"));
|
||||||
|
|
||||||
|
if(content.indexOf(".") > -1){
|
||||||
|
var module_name = content.split(" ")[0].split(".")[0]
|
||||||
|
}
|
||||||
|
else if(content.indexOf(":") > -1){
|
||||||
|
var module_name = content.split(" ")[0].split(":")[0]
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
var module_name = content.split(" ")[0];
|
||||||
|
}
|
||||||
|
|
||||||
var method_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[1] : "default";
|
var method_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[1] : "default";
|
||||||
|
var setting_name = content.indexOf(":") > -1 ? content.split(" ")[0].split(":")[1] : null;
|
||||||
|
|
||||||
var parameters = content.split(" "); parameters.shift();
|
var parameters = content.split(" "); parameters.shift();
|
||||||
var parameters = new Command(parameters);
|
var parameters = new Command(parameters);
|
||||||
@ -75,6 +87,9 @@ function Terminal(rune)
|
|||||||
if(ronin[module_name] && ronin[module_name][method_name]){
|
if(ronin[module_name] && ronin[module_name][method_name]){
|
||||||
ronin[module_name][method_name](parameters);
|
ronin[module_name][method_name](parameters);
|
||||||
}
|
}
|
||||||
|
else if(ronin[module_name] && ronin[module_name].settings[setting_name]){
|
||||||
|
ronin[module_name].update_setting(setting_name,parameters);
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown module"));
|
ronin.terminal.log(new Log(ronin.terminal,"Unknown module"));
|
||||||
}
|
}
|
||||||
@ -202,6 +217,6 @@ function Log(host,message,type = "default")
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
this.element = document.createElement("log");
|
this.element = document.createElement("log");
|
||||||
this.element.setAttribute("class",type);
|
this.element.setAttribute("class",type);
|
||||||
this.element.innerHTML = "<span class='rune'>"+host.rune+"</span> "+message;
|
this.element.innerHTML = "<span class='rune'>"+(host.rune ? host.rune : ">")+"</span> "+message;
|
||||||
console.log(this.host.constructor.name,this.message)
|
console.log(this.host.constructor.name,this.message)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user