diff --git a/sources/index.html b/sources/index.html index 3496250..1c6bcfc 100644 --- a/sources/index.html +++ b/sources/index.html @@ -1,5 +1,7 @@
+ + diff --git a/sources/scripts/commander.js b/sources/scripts/commander.js index a7a1c2f..d790c43 100644 --- a/sources/scripts/commander.js +++ b/sources/scripts/commander.js @@ -33,7 +33,6 @@ function Commander() ronin.modules[q.module].methods[method_id](method_param); } - ronin.commander.input_el.value = ""; ronin.hint.update(); ronin.guide.update(); @@ -41,6 +40,7 @@ function Commander() this.on_input = function(e) { + console.log("input"); ronin.hint.update(); ronin.guide.update(); } diff --git a/sources/scripts/layers/guide.js b/sources/scripts/layers/guide.js index 3779be4..e50ef11 100644 --- a/sources/scripts/layers/guide.js +++ b/sources/scripts/layers/guide.js @@ -11,7 +11,8 @@ function Guide() this.el.style.width = (window.innerWidth)+"px"; this.el.style.height = (window.innerHeight)+"px"; - var u = ronin.guide.find_unit(); + var u = this.find_unit(); + console.log("found:",u) if(!u){ return; } this.clear(); @@ -80,6 +81,9 @@ function Guide() this.find_unit = function(q = ronin.commander.query()) { + if(q.settings.anchor){ return q.settings.anchor; } + + console.log("-----",q.settings) for(method_id in q.methods){ var params = q.methods[method_id]; if(!params){ return null; } @@ -87,6 +91,14 @@ function Guide() if(params[0]){ return params[0]; } return params; } + + for(method_id in q.settings){ + var params = q.settings[method_id]; + if(!params){ return null; } + if(params[0]){ return params[0]; } + return params; + } + return null; } } \ No newline at end of file diff --git a/sources/scripts/modules/io.js b/sources/scripts/modules/io.js index 1dc0c2d..08630f6 100644 --- a/sources/scripts/modules/io.js +++ b/sources/scripts/modules/io.js @@ -2,7 +2,7 @@ function IO() { Module.call(this,"io"); - this.settings = {rect:"25,25|200x200"}; + this.settings = {anchor:{x:0,y:0,width:0,height:0}}; this.methods = {}; @@ -17,9 +17,9 @@ function IO() var img = new Image(); img.src = filepath[0]; - + img.onload = function() { - ronin.io.draw_image(img); + ronin.io.draw_image(img,ronin.commander.query()); } }); } @@ -81,17 +81,14 @@ function IO() } } - this.draw_image = function(img) + this.draw_image = function(img,params) { + var anchor = ronin.io.settings.anchor; + var width = parseInt(img.naturalWidth * 0.5); var height = parseInt(img.naturalHeight * 0.5); + var scale = (anchor.width/width) * 2; - if(height > 900){ - width *= 0.5; - height *= 0.5; - } - - console.log(width,height); - ronin.render.context().drawImage(img, 0,0,width * 2,height * 2); + ronin.render.context().drawImage(img, anchor.x * 2,anchor.y * 2,width * scale,height * scale); } } \ No newline at end of file diff --git a/sources/scripts/query.js b/sources/scripts/query.js index 094aa0e..dc019b5 100644 --- a/sources/scripts/query.js +++ b/sources/scripts/query.js @@ -1,4 +1,4 @@ -function Query(query_str) +function Query(query_str = "") { this.module = query_str.split(" ")[0]; var parts = query_str.split(" ").splice(1); @@ -9,16 +9,19 @@ function Query(query_str) for(part_id in parts){ var part = parts[part_id]; + // Method if(part.indexOf(":") > -1){ var key = part.indexOf(":") > -1 ? part.split(":")[0] : "any"; var value = part.indexOf(":") > -1 ? part.split(":")[1] : part; this.methods[key] = parse_parameters(value); } + // Setting else if(part.indexOf("=") > -1){ var key = part.indexOf("=") > -1 ? part.split("=")[0] : "any"; var value = part.indexOf("=") > -1 ? part.split("=")[1] : part; - this.settings[key] = value; + this.settings[key] = parse_parameters(value); } + // Port else if(part.indexOf("->") > -1){ var key = part.indexOf("->") > -1 ? part.split("->")[0] : "any"; var value = part.indexOf("->") > -1 ? part.split("->")[1] : part; @@ -28,6 +31,7 @@ function Query(query_str) function parse_parameters(param_str) { + // Modifier if(param_str.indexOf(">>") > -1){ return parse_modifier(param_str); } diff --git a/sources/scripts/ronin.js b/sources/scripts/ronin.js index 18e79bd..abaae71 100644 --- a/sources/scripts/ronin.js +++ b/sources/scripts/ronin.js @@ -64,6 +64,6 @@ function Ronin() this.grid.update(); this.guide.update(); - this.commander.input_el.value = "io import:~/Desktop/test.png rect=$"; + this.commander.input_el.value = "io import:~/Desktop/test.png anchor=$"; } } \ No newline at end of file diff --git a/sources/scripts/units/rect.js b/sources/scripts/units/rect.js new file mode 100644 index 0000000..3e60396 --- /dev/null +++ b/sources/scripts/units/rect.js @@ -0,0 +1,4 @@ +function Rect(rect_str) +{ + +} \ No newline at end of file