Began working on methods
This commit is contained in:
parent
15e019d455
commit
35438605af
@ -11,6 +11,7 @@
|
||||
<script type="text/javascript" src="scripts/units/any.js"></script>
|
||||
<script type="text/javascript" src="scripts/units/setting.js"></script>
|
||||
<script type="text/javascript" src="scripts/units/range.js"></script>
|
||||
<script type="text/javascript" src="scripts/units/method.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/modules/default.js"></script>
|
||||
<script type="text/javascript" src="scripts/modules/cursor.js"></script>
|
||||
|
@ -84,8 +84,8 @@ function Command(content)
|
||||
this.setting = function(name)
|
||||
{
|
||||
for (i = 0; i < this.content.length; i++) {
|
||||
if(this.content[i].indexOf(":") >= 0){
|
||||
var parts = this.content[i].split(":");
|
||||
if(this.content[i].indexOf("=") >= 0){
|
||||
var parts = this.content[i].split("=");
|
||||
if(parts[0] == name){
|
||||
return new Setting(parts[0],parts[1]);
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ 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("@ size:"+starting_canvas.render());
|
||||
ronin.terminal.query("@ layer:Main");
|
||||
ronin.terminal.query("- color:#ff0000");
|
||||
ronin.terminal.query("@ size="+starting_canvas.render());
|
||||
ronin.terminal.query("@ layer=Main");
|
||||
ronin.terminal.query("- color=#ff0000");
|
||||
// ronin.terminal.query("# fill=#ff0000");
|
||||
// ronin.terminal.query("- 0,0");
|
||||
// ronin.terminal.query("- 1,1");
|
||||
|
@ -19,13 +19,13 @@ function Ronin()
|
||||
this.modules[this.surface.rune] = this.surface;
|
||||
this.modules[this.fileload.rune] = this.fileload;
|
||||
this.modules[this.filesave.rune] = this.filesave;
|
||||
this.modules[this.overlay.rune] = this.overlay;
|
||||
this.modules[this.render.rune] = this.render;
|
||||
this.modules[this.brush.rune] = this.brush;
|
||||
this.modules[this.eye.rune] = this.eye;
|
||||
this.modules[this.typo.rune] = this.typo;
|
||||
this.modules[this.vector.rune] = this.vector;
|
||||
this.modules[this.terminal.rune] = this.terminal;
|
||||
this.modules[this.overlay.rune] = this.overlay;
|
||||
|
||||
this.modules[this.cursor.rune] = this.cursor;
|
||||
|
||||
|
@ -79,7 +79,7 @@ function Brush(rune)
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
return ronin.cursor.draw_pointer_circle(position,this.settings["size"]);
|
||||
return ronin.cursor.draw_pointer_circle(position,this.settings["size"].float);
|
||||
}
|
||||
|
||||
this.mouse_mode = function()
|
||||
|
@ -96,7 +96,40 @@ function Cursor(rune)
|
||||
this.pointer_last = this.pointer_last ? this.pointer_last : position;
|
||||
|
||||
this.layer.context().beginPath();
|
||||
this.layer.context().arc(position.x, position.y, 3.5, 0, 2 * Math.PI, false);
|
||||
this.layer.context().moveTo(this.pointer_last.x,this.pointer_last.y);
|
||||
this.layer.context().lineTo(position.x,position.y);
|
||||
this.layer.context().lineCap="round";
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = "white";
|
||||
this.layer.context().stroke();
|
||||
this.layer.context().closePath();
|
||||
|
||||
this.layer.context().beginPath();
|
||||
this.layer.context().arc(position.x, position.y, size+1, 0, 2 * Math.PI, false);
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = "white";
|
||||
this.layer.context().stroke();
|
||||
this.layer.context().closePath();
|
||||
|
||||
this.pointer_last = position;
|
||||
}
|
||||
|
||||
this.draw_pointer_drag = function(position)
|
||||
{
|
||||
if(!this.layer){ this.create_layer(); }
|
||||
|
||||
this.pointer_last = this.pointer_last ? this.pointer_last : position;
|
||||
|
||||
this.layer.context().beginPath();
|
||||
|
||||
this.layer.context().moveTo(position.x,position.y - 3);
|
||||
this.layer.context().lineTo(position.x,position.y + 3);
|
||||
this.layer.context().moveTo(position.x - 2,position.y - 3);
|
||||
this.layer.context().lineTo(position.x - 2,position.y + 3);
|
||||
this.layer.context().moveTo(position.x + 2,position.y - 3);
|
||||
this.layer.context().lineTo(position.x + 2,position.y + 3);
|
||||
|
||||
this.layer.context().lineCap="round";
|
||||
this.layer.context().lineWidth = 1;
|
||||
this.layer.context().strokeStyle = "white";
|
||||
this.layer.context().stroke();
|
||||
|
@ -9,6 +9,11 @@ function Default(rune)
|
||||
return "Drag";
|
||||
}
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
return ronin.cursor.draw_pointer_drag(position);
|
||||
}
|
||||
|
||||
this.drag_from = null;
|
||||
this.drag_offset_x = 0;
|
||||
this.drag_offset_y = 0;
|
||||
|
@ -3,6 +3,7 @@ function Module(rune)
|
||||
this.rune = rune;
|
||||
this.element = null;
|
||||
this.settings = {};
|
||||
this.methods = {};
|
||||
this.layer = null;
|
||||
|
||||
this.docs = "Missing documentation.";
|
||||
@ -50,7 +51,10 @@ function Module(rune)
|
||||
var h = "<b>"+ronin.module.constructor.name+"</b> ";
|
||||
|
||||
for(setting in ronin.module.settings){
|
||||
h += setting+":"+ronin.module.settings[setting].render()+" ";
|
||||
h += setting+"="+ronin.module.settings[setting].render()+" ";
|
||||
}
|
||||
for(method in ronin.module.methods){
|
||||
h += ronin.module.methods[method].render()+" ";
|
||||
}
|
||||
|
||||
h += ronin.module.mouse_mode() ? "<i>"+ronin.module.mouse_mode()+"</i>" : "";
|
||||
|
@ -4,6 +4,7 @@ function Surface(rune)
|
||||
|
||||
this.element = null;
|
||||
this.settings = {"size":new Rect("200x200")};
|
||||
this.methods = {"layer":new Method("layer",["name"])}
|
||||
|
||||
this.layers = {};
|
||||
this.active_layer = null;
|
||||
|
@ -1,6 +1,7 @@
|
||||
function Layer(name,manager = null)
|
||||
{
|
||||
this.rune = "@";
|
||||
Module.call(this,"#");
|
||||
|
||||
this.name = name;
|
||||
this.manager = manager;
|
||||
this.element = document.createElement("canvas");
|
||||
@ -68,6 +69,11 @@ function Layer(name,manager = null)
|
||||
return "<span class='"+e_class+"'>"+e_name+"</span>";
|
||||
}
|
||||
|
||||
this.mouse_pointer = function(position)
|
||||
{
|
||||
return ronin.cursor.draw_pointer_drag(position);
|
||||
}
|
||||
|
||||
this.mouse_mode = function()
|
||||
{
|
||||
return "Move";
|
||||
|
@ -2,8 +2,8 @@ function Typographe(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Position,Color,Value];
|
||||
this.variables = {"text" : null, "font" : "Georgia"};
|
||||
this.settings = {"color":new Color("#ffffff"),"size":new Value(10)};
|
||||
this.methods = {"draw":new Method("draw",["text","position","font"])}
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
|
19
scripts/units/method.js
Normal file
19
scripts/units/method.js
Normal file
@ -0,0 +1,19 @@
|
||||
function Method(name,params)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
this.example = "";
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
var s = name+":";
|
||||
for(param in this.params){
|
||||
s += this.params[param]+","
|
||||
}
|
||||
s = s.substr(0,s.length-1);
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user