Implemented globals for scale and color
This commit is contained in:
@@ -68,14 +68,16 @@ function Commander()
|
||||
|
||||
this.autocomplete = function()
|
||||
{
|
||||
|
||||
var target_module = ronin.commander.query().module;
|
||||
|
||||
var ac = ronin.modules[target_module] ? ronin.hint.find_autocomplete(ronin.modules[target_module].methods,":") : ronin.hint.find_autocomplete(ronin.modules," ")
|
||||
|
||||
this.focus();
|
||||
if(ac.lenght < 1 || !ac[0]){ return; }
|
||||
if(ronin.commander.query().string.length < 1){ return; }
|
||||
|
||||
this.append(ac[0]);
|
||||
this.focus();
|
||||
}
|
||||
|
||||
this.on_input = function(e)
|
||||
|
||||
@@ -8,7 +8,7 @@ function Cursor(rune)
|
||||
this.query = null;
|
||||
this.mode = "vertex";
|
||||
|
||||
this.color = "#f0f"
|
||||
this.color = "#f00"
|
||||
this.size = 4;
|
||||
|
||||
this.draw_cursor = function(pos,touch = false)
|
||||
@@ -35,6 +35,14 @@ function Cursor(rune)
|
||||
|
||||
var pos = ronin.magnet.filter({x:e.clientX,y:e.clientY});
|
||||
|
||||
// Color Pick
|
||||
if(ronin.commander.input_el.value == "~"){
|
||||
ronin.brush.methods.pick.run({x:pos.x,y:pos.y})
|
||||
ronin.commander.input_el.value = "";
|
||||
ronin.commander.update();
|
||||
return;
|
||||
}
|
||||
|
||||
ronin.cursor.draw_cursor({x:pos.x,y:pos.y},true);
|
||||
|
||||
ronin.cursor.line.origin = {x:pos.x,y:pos.y};
|
||||
@@ -43,6 +51,10 @@ function Cursor(rune)
|
||||
// Save original query
|
||||
ronin.cursor.query = ronin.commander.input_el.value;
|
||||
|
||||
if(e.altKey && e.shiftKey){
|
||||
ronin.brush.methods.pick.run(pos);
|
||||
}
|
||||
|
||||
if(e.shiftKey){ ronin.cursor.mode = "rect"; }
|
||||
if(e.altKey){ ronin.cursor.mode = "arc_to"; }
|
||||
if(e.ctrlKey){ ronin.cursor.mode = "cc_arc_to"; }
|
||||
@@ -63,8 +75,8 @@ function Cursor(rune)
|
||||
if(ronin.commander.active_module()){
|
||||
|
||||
}
|
||||
else if(e.shiftKey && e.altKey){
|
||||
ronin.brush.pick(ronin.cursor.line);
|
||||
else if(e.altKey && e.shiftKey){
|
||||
ronin.brush.methods.pick.run(pos);
|
||||
}
|
||||
else if(e.altKey){
|
||||
ronin.brush.erase(ronin.cursor.line);
|
||||
@@ -137,16 +149,50 @@ function Cursor(rune)
|
||||
str = "@<"+b.x+","+b.y;
|
||||
}
|
||||
//
|
||||
var i = ronin.cursor.query.indexOf("$");
|
||||
var i1 = ronin.cursor.query.substr(i,2);
|
||||
if(i1 == "$+"){
|
||||
var i = ronin.cursor.query ? ronin.cursor.query.indexOf("$") : '';
|
||||
var i1 = ronin.cursor.query ? ronin.cursor.query.substr(i,2) : '';
|
||||
var e1 = ronin.cursor.query ? ronin.cursor.query.substr(i-1,2) : '';
|
||||
|
||||
if(e1 == "#$"){
|
||||
var r = parseInt((b.x/ronin.frame.width) * 255);
|
||||
var g = 255 - parseInt((b.x/ronin.frame.width) * 255);
|
||||
var b = parseInt((b.y/ronin.frame.height) * 255);
|
||||
var str = new Color().rgb_to_hex([r,g,b]);
|
||||
ronin.commander.inject(ronin.cursor.query.replace("#$",str+" "));
|
||||
}
|
||||
else if(i1 == "$+"){
|
||||
ronin.commander.inject(ronin.cursor.query.replace("$+",str+"&$+"));
|
||||
}
|
||||
else{
|
||||
else if(ronin.cursor.query){
|
||||
ronin.commander.inject(ronin.cursor.query.replace("$",str));
|
||||
}
|
||||
}
|
||||
|
||||
this.hint = function()
|
||||
{
|
||||
var html = "";
|
||||
|
||||
var mode = "PAINT";
|
||||
|
||||
if(ronin.commander.input_el.value.indexOf("$+") > -1){
|
||||
mode = "[MULTI]POS/SHIFT-RECT"
|
||||
}
|
||||
else if(ronin.commander.input_el.value.indexOf("$") > -1){
|
||||
mode = "POS/SHIFT-RECT"
|
||||
}
|
||||
else if(ronin.keyboard.is_down["Alt"] && ronin.keyboard.is_down["Shift"]){
|
||||
mode = "PICK";
|
||||
}
|
||||
else if(ronin.keyboard.is_down["Alt"]){
|
||||
mode = "ERASE";
|
||||
}
|
||||
else if(ronin.keyboard.is_down["Shift"]){
|
||||
mode = "DRAG";
|
||||
}
|
||||
|
||||
return "<t class='mode'>"+mode+"</t><t class='size'>"+ronin.cursor.size+"</t> <t class='color' style='color:"+ronin.cursor.color+"'>●</t>";
|
||||
}
|
||||
|
||||
function distance_between(a,b)
|
||||
{
|
||||
return Math.sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
|
||||
|
||||
@@ -5,9 +5,13 @@ function Docs()
|
||||
var html = "";
|
||||
|
||||
html += this.print_intro();
|
||||
|
||||
html += "## Cursor\n";
|
||||
html += "- `$` replace with **Pos**.\n";
|
||||
html += "- `$+shift` replace with **Rect**.\n\n";
|
||||
html += "Include `$` in a query and click on the canvas to inject the cursor position in the query.\n";
|
||||
html += "- `$ click` inject a **Pos**.\n";
|
||||
html += "- `$+ click` inject a **Pos**, and append `$+` for multiple positions.\n";
|
||||
html += "- `$ shift click` inject a **Rect**.\n\n";
|
||||
html += "- `#$ click` inject a **Color**.\n";
|
||||
|
||||
html += "## Modules\n";
|
||||
html += this.print_modules(ronin.modules);
|
||||
@@ -23,7 +27,7 @@ function Docs()
|
||||
this.print_intro = function()
|
||||
{
|
||||
html = "# Ronin\n";
|
||||
html += "Ronin is a simple open-source graphic design tool.\n\n";
|
||||
html += "Ronin is a graphic design tool, to paint, resize and export graphics.\n\n";
|
||||
html += "<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW.jpg' width='600'/>\n\n";
|
||||
return html;
|
||||
}
|
||||
@@ -55,7 +59,7 @@ function Docs()
|
||||
this.print_license = function()
|
||||
{
|
||||
html = "## License\n";
|
||||
html += "See the [LICENSE](LICENSE.md) file for license rights and limitations (CC).\n";
|
||||
html += "See the [LICENSE](LICENSE.md) file for license rights and limitations.\n";
|
||||
return html;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,6 @@ function Hint()
|
||||
{
|
||||
ronin.commander.el.appendChild(this.el);
|
||||
ronin.commander.el.appendChild(this.cursor_hint_el);
|
||||
this.cursor_hint_el.innerHTML = "●";
|
||||
this.cursor_hint_el.title = ronin.cursor.color;
|
||||
this.cursor_hint_el.style.color = ronin.cursor.color;
|
||||
}
|
||||
|
||||
this.find_autocomplete = function(collection,append = "")
|
||||
@@ -65,6 +62,7 @@ function Hint()
|
||||
this.el.innerHTML = this.pad(ronin.commander.input_el.value)+" > Unknown command."
|
||||
}
|
||||
}
|
||||
this.cursor_hint_el.innerHTML = ronin.cursor.hint();
|
||||
}
|
||||
|
||||
this.pad = function(input)
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
function Keyboard()
|
||||
{
|
||||
this.is_down = {};
|
||||
|
||||
this.key_up = function(e)
|
||||
{
|
||||
ronin.keyboard.is_down[e.key] = false;
|
||||
ronin.hint.update(e);
|
||||
}
|
||||
|
||||
this.key_down = function(e)
|
||||
{
|
||||
ronin.keyboard.is_down[e.key] = true;
|
||||
|
||||
if(e.key == "~"){
|
||||
e.preventDefault();
|
||||
ronin.commander.inject("~")
|
||||
return;
|
||||
}
|
||||
|
||||
if(e.key == "Enter"){
|
||||
e.preventDefault();
|
||||
ronin.commander.validate();
|
||||
|
||||
Reference in New Issue
Block a user