Various updates
This commit is contained in:
@@ -11,6 +11,7 @@ function Frame(rune)
|
||||
|
||||
this.add_method(new Method("resize",[new Rect().name]));
|
||||
this.add_method(new Method("crop",[new Position().name,new Rect().name]));
|
||||
this.add_method(new Method("select",["text"]));
|
||||
|
||||
this.widget_element = document.createElement("widget");
|
||||
|
||||
@@ -53,8 +54,10 @@ function Frame(rune)
|
||||
if(preview){ronin.overlay.draw_rect(params.position(),params.rect());}
|
||||
}
|
||||
|
||||
this.select = function(params)
|
||||
this.select = function(params, preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
var layer_name = params.content;
|
||||
if(!ronin.frame.layers[layer_name]){
|
||||
this.add_layer(new Layer(layer_name));
|
||||
@@ -64,6 +67,11 @@ function Frame(rune)
|
||||
ronin.layer = this.layers[layer_name];
|
||||
}
|
||||
|
||||
this.context = function()
|
||||
{
|
||||
return this.active_layer.context();
|
||||
}
|
||||
|
||||
// Misc
|
||||
|
||||
this.blink = function()
|
||||
|
||||
@@ -2,10 +2,12 @@ function Layer(name,manager = null)
|
||||
{
|
||||
Module.call(this,"#");
|
||||
|
||||
this.add_method(new Method("fill",["color","position","rect"],"Add position"));
|
||||
this.add_method(new Method("translate",["position"]));
|
||||
this.add_method(new Method("clear",[]));
|
||||
this.add_method(new Method("rotate",["position","angle"]));
|
||||
this.add_method(new Method("resize",["position","rect"]));
|
||||
this.add_method(new Method("mirror",["position"]));
|
||||
this.add_method(new Method("fill",["color","position","rect"],"Add position"));
|
||||
|
||||
this.add_method(new Method("rename",["text"]));
|
||||
|
||||
this.name = name;
|
||||
@@ -15,6 +17,17 @@ function Layer(name,manager = null)
|
||||
this.element.setAttribute("id","_"+name);
|
||||
this.element.setAttribute("class","layer");
|
||||
|
||||
this.translate = function(params,preview = false)
|
||||
{
|
||||
if(!params.position()){ return; }
|
||||
if(preview){ return; }
|
||||
|
||||
var data = this.data();
|
||||
this.clear();
|
||||
this.context().putImageData(data, params.position().x * 2, params.position().y * 2);
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
}
|
||||
|
||||
this.fill = function(params,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
@@ -40,6 +53,13 @@ function Layer(name,manager = null)
|
||||
ronin.terminal.log(new Log(this,"Renamed layer "+this.name+" to "+params.text()));
|
||||
}
|
||||
|
||||
this.clear = function(params, preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
this.context().clearRect(0, 0, this.element.width, this.element.height);
|
||||
}
|
||||
|
||||
this.resize = function(rect)
|
||||
{
|
||||
ronin.terminal.log(new Log(this,"Resize "+this.name+" to "+rect.render()));
|
||||
@@ -54,11 +74,6 @@ function Layer(name,manager = null)
|
||||
this.context().scale(2,2);
|
||||
}
|
||||
|
||||
this.clear = function()
|
||||
{
|
||||
this.context().clearRect(0, 0, this.element.width, this.element.height);
|
||||
}
|
||||
|
||||
this.remove = function(manager)
|
||||
{
|
||||
ronin.terminal.log(new Log(this,"Removing layer "+this.name));
|
||||
@@ -77,6 +92,11 @@ function Layer(name,manager = null)
|
||||
return this.element.toDataURL('image/png');
|
||||
}
|
||||
|
||||
this.data = function()
|
||||
{
|
||||
return this.context().getImageData(0, 0, ronin.frame.settings["size"].width * 2, ronin.frame.settings["size"].height * 2);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this.widget = function()
|
||||
@@ -92,42 +112,98 @@ function Layer(name,manager = null)
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
return ronin.cursor.draw_pointer_drag(position);
|
||||
return ronin.cursor.draw_pointer_arrow(position);
|
||||
}
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
return "Move";
|
||||
}
|
||||
|
||||
this.move_from = null;
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.move_from = ronin.position_in_window(position);
|
||||
ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" 0,0";
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(this.move_from === null){ return; }
|
||||
var offset = new Position((-this.mouse_from.x + position.x)+","+(-this.mouse_from.y + position.y));
|
||||
|
||||
position = ronin.position_in_window(position);
|
||||
|
||||
var offset_x = this.move_from.x - position.x;
|
||||
var offset_y = this.move_from.y - position.y;
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
ronin.overlay.draw_cross(this.mouse_from);
|
||||
ronin.overlay.draw_cross(position);
|
||||
ronin.overlay.draw_line(this.mouse_from,position);
|
||||
|
||||
var imageData = this.context().getImageData(0, 0, ronin.frame.settings["size"].width * 2, ronin.frame.settings["size"].height * 2);
|
||||
this.clear();
|
||||
this.context().putImageData(imageData, -offset_x * 2, -offset_y * 2);
|
||||
|
||||
this.move_from = new Position(position.x,position.y);
|
||||
|
||||
ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" "+offset.render();
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
this.mouse_up = function(event)
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
this.move_from = null;
|
||||
var offset = new Position((-this.mouse_from.x + position.x)+","+(-this.mouse_from.y + position.y));
|
||||
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
ronin.overlay.draw_circle(position);
|
||||
ronin.overlay.draw_circle(this.mouse_from);
|
||||
ronin.overlay.draw_line(this.mouse_from,position);
|
||||
|
||||
ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" "+offset.render();
|
||||
ronin.terminal.passive();
|
||||
|
||||
// if(this.coordinates.length == 0){
|
||||
// this.coordinates.push("M"+position.render());
|
||||
// }
|
||||
// else{
|
||||
// var offset = this.last_pos ? position.offset(this.last_pos) : position;
|
||||
|
||||
// if(keyboard.shift_held == true && keyboard.alt_held == true){
|
||||
// this.coordinates.push("M"+position.render());
|
||||
// }
|
||||
// else if(keyboard.shift_held == true){
|
||||
// this.coordinates.push("a"+offset.render()+" 0 0,1 "+offset.render());
|
||||
// }
|
||||
// else if(keyboard.alt_held == true){
|
||||
// this.coordinates.push("a"+offset.render()+" 0 0,0 "+offset.render());
|
||||
// }
|
||||
// else{
|
||||
// this.coordinates.push("l"+offset.render());
|
||||
// }
|
||||
// }
|
||||
|
||||
// ronin.terminal.input_element.value = "path."+ronin.terminal.method_name+" "+this.create_path();
|
||||
// this.last_pos = position;
|
||||
// ronin.terminal.passive();
|
||||
}
|
||||
|
||||
// this.move_from = null;
|
||||
|
||||
// this.mouse_down = function(position)
|
||||
// {
|
||||
// this.move_from = ronin.position_in_window(position);
|
||||
// }
|
||||
|
||||
// this.mouse_move = function(position)
|
||||
// {
|
||||
// if(this.move_from === null){ return; }
|
||||
|
||||
// position = ronin.position_in_window(position);
|
||||
|
||||
// var offset_x = this.move_from.x - position.x;
|
||||
// var offset_y = this.move_from.y - position.y;
|
||||
|
||||
// var imageData = this.context().getImageData(0, 0, ronin.frame.settings["size"].width * 2, ronin.frame.settings["size"].height * 2);
|
||||
// this.clear();
|
||||
// this.context().putImageData(imageData, -offset_x * 2, -offset_y * 2);
|
||||
|
||||
// this.move_from = new Position(position.x,position.y);
|
||||
|
||||
// }
|
||||
|
||||
// this.mouse_up = function(event)
|
||||
// {
|
||||
// this.move_from = null;
|
||||
// }
|
||||
|
||||
// Blink
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ function Module(rune)
|
||||
this.update_setting = function(name,value)
|
||||
{
|
||||
this.settings[name] = value.content.join(" ");
|
||||
ronin.terminal.log(new Log(this,"Updated setting: "+name));
|
||||
ronin.terminal.log(new Log(this,"Updated setting: "+name+", to "+this.settings[name]));
|
||||
}
|
||||
|
||||
this.add_method = function(method)
|
||||
|
||||
@@ -99,6 +99,50 @@ function Overlay(rune)
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_line = function(position,to)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(position.x,position.y);
|
||||
this.context().lineTo(to.x,to.y);
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = this.color.hex;
|
||||
this.context().stroke();
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_circle = function(position,radius = 5)
|
||||
{
|
||||
this.context().beginPath();
|
||||
this.context().arc(position.x, position.y, radius, 0, 2 * Math.PI, false);
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = "white";
|
||||
this.context().stroke();
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_cross = function(position,radius = 5)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
this.context().moveTo(position.x+(radius-2),position.y);
|
||||
this.context().lineTo(position.x+radius,position.y);
|
||||
this.context().moveTo(position.x-(radius-2),position.y);
|
||||
this.context().lineTo(position.x-radius,position.y);
|
||||
this.context().moveTo(position.x,position.y+(radius-2));
|
||||
this.context().lineTo(position.x,position.y+radius);
|
||||
this.context().moveTo(position.x,position.y-(radius-2));
|
||||
this.context().lineTo(position.x,position.y-radius);
|
||||
|
||||
this.context().lineCap="round";
|
||||
this.context().lineWidth = 1;
|
||||
this.context().strokeStyle = this.color.hex;
|
||||
this.context().stroke();
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
this.draw_vertical_line = function(position)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
@@ -16,14 +16,19 @@ function Path(rune)
|
||||
{
|
||||
if(!ronin.path.layer){ ronin.path.create_layer(); ronin.path.layer.is_blinking = true; }
|
||||
|
||||
ronin.terminal.log(new Log(this,"Stroke path!("+preview+")"));
|
||||
|
||||
this.layer.clear();
|
||||
|
||||
var target_layer = preview ? this.layer : ronin.frame.active_layer;
|
||||
var context = preview ? this.context() : ronin.frame.context();
|
||||
|
||||
target_layer.context().lineCap = this.settings["line_cap"];
|
||||
target_layer.context().lineWidth = this.settings["line_width"];
|
||||
target_layer.context().strokeStyle = this.settings["line_color"];
|
||||
target_layer.context().stroke(new Path2D(params.content));
|
||||
console.log(this.settings["line_width"]);
|
||||
context.beginPath();
|
||||
context.lineCap = this.settings["line_cap"];
|
||||
context.lineWidth = this.settings["line_width"];
|
||||
context.strokeStyle = this.settings["line_color"];
|
||||
context.stroke(new Path2D(params.content));
|
||||
context.closePath();
|
||||
}
|
||||
|
||||
this.fill = function(params,preview = false)
|
||||
|
||||
@@ -10,6 +10,15 @@ function Terminal(rune)
|
||||
|
||||
this.history = [];
|
||||
|
||||
this.add_method(new Method("save",["text"]));
|
||||
this.add_method(new Method("display",["mini/hide/full"]));
|
||||
|
||||
this.display = function(params,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
this.element.setAttribute("class",params.content);
|
||||
}
|
||||
|
||||
// Module
|
||||
this.install = function(cmd)
|
||||
{
|
||||
@@ -66,7 +75,7 @@ function Terminal(rune)
|
||||
|
||||
function active(content)
|
||||
{
|
||||
ronin.terminal.log(new Log(this,content,"input"));
|
||||
ronin.terminal.log(new Log(ronin.terminal,content,"input"));
|
||||
|
||||
if(content.indexOf(".") > -1){
|
||||
var module_name = content.split(" ")[0].split(".")[0]
|
||||
@@ -90,8 +99,11 @@ function Terminal(rune)
|
||||
else if(ronin[module_name] && ronin[module_name].settings[setting_name]){
|
||||
ronin[module_name].update_setting(setting_name,parameters);
|
||||
}
|
||||
else if(ronin[module_name]){
|
||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown method: "+method_name));
|
||||
}
|
||||
else{
|
||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown module"));
|
||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown module: "+module_name));
|
||||
}
|
||||
|
||||
// var key = content[0];
|
||||
|
||||
@@ -15,13 +15,15 @@ function Type(rune)
|
||||
var text = params.text() ? params.text() : "Placeholder";
|
||||
var position = params.position() ? params.position() : new Position(40,80);
|
||||
var color = params.color() ? params.color() :new Color("#ffffff");
|
||||
var size = 40;
|
||||
var font = "Georgia";
|
||||
var size = this.settings["size"];
|
||||
var font = this.settings["font"];
|
||||
|
||||
var target_layer = preview ? this.layer : ronin.frame.active_layer;
|
||||
target_layer.context().font = size+"px "+font;
|
||||
target_layer.context().fillStyle = color.hex;
|
||||
target_layer.context().fillText(text,position.x,position.y);
|
||||
|
||||
console.log(target_layer.context());
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
Reference in New Issue
Block a user