Improved Vector and Magnet
This commit is contained in:
parent
d0d1118d3f
commit
e6f7f62d0b
34
README.md
34
README.md
@ -5,6 +5,40 @@ The repository comes with a script that fires Ronin from within Localhost.
|
|||||||
Launch Ronin and press **:**(colon) to display the command prompt.
|
Launch Ronin and press **:**(colon) to display the command prompt.
|
||||||
Enjoy
|
Enjoy
|
||||||
|
|
||||||
|
## TODOs
|
||||||
|
General
|
||||||
|
Splash screen
|
||||||
|
Hide widget on mouseover
|
||||||
|
Add locks
|
||||||
|
Store values in modules, experiment with vector
|
||||||
|
Give name to settings
|
||||||
|
Merge layers
|
||||||
|
Export multiple layers file
|
||||||
|
% Render
|
||||||
|
balance auto=true ~ auto color
|
||||||
|
balance 0.8 ~ equal RGB balance
|
||||||
|
mirror ,100 ~ mirror
|
||||||
|
Brush
|
||||||
|
Texture paint
|
||||||
|
Save
|
||||||
|
$ 1280x800 ~ Export with size
|
||||||
|
Auto saveAs
|
||||||
|
History
|
||||||
|
Undo shortcut
|
||||||
|
> Terminal
|
||||||
|
Auto Complete
|
||||||
|
Progress update
|
||||||
|
Scroll logs
|
||||||
|
Expand logs
|
||||||
|
? Interrog
|
||||||
|
Inline Help
|
||||||
|
/ Load
|
||||||
|
Load .rin files, instead of "Presets"
|
||||||
|
Load default.rin on startup
|
||||||
|
* Eye
|
||||||
|
Swatches, handle all colors
|
||||||
|
|
||||||
|
|
||||||
this.collection = {};
|
this.collection = {};
|
||||||
this.collection["grid"] = {};
|
this.collection["grid"] = {};
|
||||||
this.collection["grid"]["glyph"] = "@ 300x300; @ layer=background ; @ #A1A1A1 ; . 15x15 4,4 ; @ layer=main";
|
this.collection["grid"]["glyph"] = "@ 300x300; @ layer=background ; @ #A1A1A1 ; . 15x15 4,4 ; @ layer=main";
|
||||||
|
@ -155,12 +155,12 @@ function Cursor(rune)
|
|||||||
{
|
{
|
||||||
if(this.layer){ this.layer.clear(); }
|
if(this.layer){ this.layer.clear(); }
|
||||||
|
|
||||||
this.position = position;
|
this.position = ronin.magnet.update_mouse(position);
|
||||||
|
|
||||||
if(this.mode.constructor.name != Cursor.name){
|
if(this.mode.constructor.name != Cursor.name){
|
||||||
this.mode.mouse_from = position;
|
this.mode.mouse_from = this.position;
|
||||||
this.mode.mouse_held = true;
|
this.mode.mouse_held = true;
|
||||||
this.mode.mouse_down(position);
|
this.mode.mouse_down(this.position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,33 +170,33 @@ function Cursor(rune)
|
|||||||
|
|
||||||
this.layer.clear();
|
this.layer.clear();
|
||||||
|
|
||||||
if(this.mode){this.mode.mouse_pointer(position);}
|
this.position = ronin.magnet.update_mouse(position);
|
||||||
else{ this.mouse_pointer(position);}
|
|
||||||
|
if(this.mode){this.mode.mouse_pointer(this.position);}
|
||||||
|
else{ this.mouse_pointer(this.position);}
|
||||||
|
|
||||||
if(this.mode.mouse_from == null){ return; }
|
if(this.mode.mouse_from == null){ return; }
|
||||||
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
var rect = new Rect();
|
var rect = new Rect();
|
||||||
rect.width = this.position.x - this.mode.mouse_from.x;
|
rect.width = this.position.x - this.mode.mouse_from.x;
|
||||||
rect.height = this.position.y - this.mode.mouse_from.y;
|
rect.height = this.position.y - this.mode.mouse_from.y;
|
||||||
|
|
||||||
if(this.mode.constructor.name != Cursor.name){
|
if(this.mode.constructor.name != Cursor.name){
|
||||||
this.mode.mouse_move(position,rect);
|
this.mode.mouse_move(this.position,rect);
|
||||||
this.mode.mouse_prev = position;
|
this.mode.mouse_prev = this.position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mouse_up = function(position)
|
this.mouse_up = function(position)
|
||||||
{
|
{
|
||||||
this.position = position;
|
this.position = ronin.magnet.update_mouse(position);
|
||||||
|
|
||||||
var rect = new Rect();
|
var rect = new Rect();
|
||||||
rect.width = this.position.x - this.mode.mouse_from.x;
|
rect.width = this.position.x - this.mode.mouse_from.x;
|
||||||
rect.height = this.position.y - this.mode.mouse_from.y;
|
rect.height = this.position.y - this.mode.mouse_from.y;
|
||||||
|
|
||||||
if(this.mode.constructor.name != Cursor.name){
|
if(this.mode.constructor.name != Cursor.name){
|
||||||
this.mode.mouse_up(position,rect);
|
this.mode.mouse_up(this.position,rect);
|
||||||
this.mode.mouse_held = false;
|
this.mode.mouse_held = false;
|
||||||
}
|
}
|
||||||
ronin.terminal.input_element.focus();
|
ronin.terminal.input_element.focus();
|
||||||
|
@ -2,14 +2,14 @@ function Magnet(rune)
|
|||||||
{
|
{
|
||||||
Module.call(this,rune);
|
Module.call(this,rune);
|
||||||
|
|
||||||
this.settings = {"grid" : new Rect("0x0"), "marker": new Position("4,4"), "reset" : new Bang()};
|
this.settings = {"grid" : new Rect("1x1"), "marker": new Position("4,4"), "reset" : new Bang()};
|
||||||
|
|
||||||
this.passive = function(cmd)
|
this.passive = function(cmd)
|
||||||
{
|
{
|
||||||
if(!this.layer){ this.create_layer(); }
|
if(!this.layer){ this.create_layer(); }
|
||||||
|
|
||||||
this.layer.clear();
|
this.layer.clear();
|
||||||
this.draw(cmd.setting("grid"),cmd.setting("marker"));
|
this.draw_grid(cmd.setting("grid"),cmd.setting("marker"));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.active = function(cmd)
|
this.active = function(cmd)
|
||||||
@ -22,10 +22,17 @@ function Magnet(rune)
|
|||||||
if(!this.layer){ this.create_layer(); }
|
if(!this.layer){ this.create_layer(); }
|
||||||
|
|
||||||
this.layer.clear();
|
this.layer.clear();
|
||||||
this.draw(this.setting("grid"),this.setting("marker"));
|
this.draw_grid(this.settings["grid"],this.settings["marker"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.draw = function(rect,grid)
|
this.context = function()
|
||||||
|
{
|
||||||
|
if(!this.layer){ this.create_layer(); }
|
||||||
|
|
||||||
|
return this.layer.context();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.draw_grid = function(rect,grid)
|
||||||
{
|
{
|
||||||
if(!rect){ rect = new Rect("20x20"); }
|
if(!rect){ rect = new Rect("20x20"); }
|
||||||
if(!grid){ grid = new Position("4,4"); }
|
if(!grid){ grid = new Position("4,4"); }
|
||||||
@ -45,13 +52,24 @@ function Magnet(rune)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.draw_helper = function(position)
|
||||||
|
{
|
||||||
|
var magnetized = this.magnetic_position(position);
|
||||||
|
this.context().beginPath();
|
||||||
|
this.context().arc(magnetized.x, magnetized.y, 4, 0, 2 * Math.PI, false);
|
||||||
|
this.context().strokeStyle = 'white';
|
||||||
|
this.context().stroke();
|
||||||
|
this.context().closePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.draw_marker = function(position,size = 0.5)
|
this.draw_marker = function(position,size = 0.5)
|
||||||
{
|
{
|
||||||
var context = this.layer.context();
|
this.context().beginPath();
|
||||||
context.beginPath();
|
this.context().arc(position.x, position.y, size, 0, 2 * Math.PI, false);
|
||||||
context.arc(position.x, position.y, size, 0, 2 * Math.PI, false);
|
this.context().fillStyle = 'white';
|
||||||
context.fillStyle = 'white';
|
this.context().fill();
|
||||||
context.fill();
|
this.context().closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.magnetic_position = function(position)
|
this.magnetic_position = function(position)
|
||||||
@ -62,6 +80,18 @@ function Magnet(rune)
|
|||||||
return new Position(x,y);
|
return new Position(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.update_mouse = function(position)
|
||||||
|
{
|
||||||
|
if(!this.layer){ this.create_layer(); }
|
||||||
|
|
||||||
|
this.layer.clear();
|
||||||
|
|
||||||
|
this.draw_helper(position);
|
||||||
|
this.draw_grid(this.settings["grid"],this.settings["marker"]);
|
||||||
|
|
||||||
|
return this.magnetic_position(position);
|
||||||
|
}
|
||||||
|
|
||||||
this.key_escape = function()
|
this.key_escape = function()
|
||||||
{
|
{
|
||||||
if(this.layer){ this.layer.remove(this); }
|
if(this.layer){ this.layer.remove(this); }
|
||||||
|
@ -127,12 +127,6 @@ function Overlay(rune)
|
|||||||
this.context().closePath();
|
this.context().closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.context = function()
|
|
||||||
{
|
|
||||||
if(!this.layer){ this.create_layer(); this.layer.is_blinking = true; }
|
|
||||||
return this.layer.context();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.clear = function()
|
this.clear = function()
|
||||||
{
|
{
|
||||||
this.context().clearRect(0, 0, ronin.surface.settings["size"].width, ronin.surface.settings["size"].height);
|
this.context().clearRect(0, 0, ronin.surface.settings["size"].width, ronin.surface.settings["size"].height);
|
||||||
|
@ -13,7 +13,7 @@ function Vector(rune)
|
|||||||
|
|
||||||
this.passive = function(cmd)
|
this.passive = function(cmd)
|
||||||
{
|
{
|
||||||
if(!ronin.vector.layer){ ronin.vector.create_layer(); }
|
if(!ronin.vector.layer){ ronin.vector.create_layer(); ronin.vector.layer.is_blinking = true; }
|
||||||
|
|
||||||
this.layer.clear();
|
this.layer.clear();
|
||||||
this.layer.context().lineCap = cmd.setting("line_cap") ? cmd.setting("line_cap").value : "square";
|
this.layer.context().lineCap = cmd.setting("line_cap") ? cmd.setting("line_cap").value : "square";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user