io.import is working again
This commit is contained in:
parent
2dbfe4d2f0
commit
f568911e8c
@ -1,5 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<script type="text/javascript" src="scripts/units/rect.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="scripts/module.js"></script>
|
<script type="text/javascript" src="scripts/module.js"></script>
|
||||||
<script type="text/javascript" src="scripts/modules/frame.js"></script>
|
<script type="text/javascript" src="scripts/modules/frame.js"></script>
|
||||||
<script type="text/javascript" src="scripts/modules/brush.js"></script>
|
<script type="text/javascript" src="scripts/modules/brush.js"></script>
|
||||||
|
@ -33,7 +33,6 @@ function Commander()
|
|||||||
ronin.modules[q.module].methods[method_id](method_param);
|
ronin.modules[q.module].methods[method_id](method_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ronin.commander.input_el.value = "";
|
ronin.commander.input_el.value = "";
|
||||||
ronin.hint.update();
|
ronin.hint.update();
|
||||||
ronin.guide.update();
|
ronin.guide.update();
|
||||||
@ -41,6 +40,7 @@ function Commander()
|
|||||||
|
|
||||||
this.on_input = function(e)
|
this.on_input = function(e)
|
||||||
{
|
{
|
||||||
|
console.log("input");
|
||||||
ronin.hint.update();
|
ronin.hint.update();
|
||||||
ronin.guide.update();
|
ronin.guide.update();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ function Guide()
|
|||||||
this.el.style.width = (window.innerWidth)+"px";
|
this.el.style.width = (window.innerWidth)+"px";
|
||||||
this.el.style.height = (window.innerHeight)+"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; }
|
if(!u){ return; }
|
||||||
|
|
||||||
this.clear();
|
this.clear();
|
||||||
@ -80,6 +81,9 @@ function Guide()
|
|||||||
|
|
||||||
this.find_unit = function(q = ronin.commander.query())
|
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){
|
for(method_id in q.methods){
|
||||||
var params = q.methods[method_id];
|
var params = q.methods[method_id];
|
||||||
if(!params){ return null; }
|
if(!params){ return null; }
|
||||||
@ -87,6 +91,14 @@ function Guide()
|
|||||||
if(params[0]){ return params[0]; }
|
if(params[0]){ return params[0]; }
|
||||||
return params;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ function IO()
|
|||||||
{
|
{
|
||||||
Module.call(this,"io");
|
Module.call(this,"io");
|
||||||
|
|
||||||
this.settings = {rect:"25,25|200x200"};
|
this.settings = {anchor:{x:0,y:0,width:0,height:0}};
|
||||||
|
|
||||||
this.methods = {};
|
this.methods = {};
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ function IO()
|
|||||||
img.src = filepath[0];
|
img.src = filepath[0];
|
||||||
|
|
||||||
img.onload = function() {
|
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 width = parseInt(img.naturalWidth * 0.5);
|
||||||
var height = parseInt(img.naturalHeight * 0.5);
|
var height = parseInt(img.naturalHeight * 0.5);
|
||||||
|
var scale = (anchor.width/width) * 2;
|
||||||
|
|
||||||
if(height > 900){
|
ronin.render.context().drawImage(img, anchor.x * 2,anchor.y * 2,width * scale,height * scale);
|
||||||
width *= 0.5;
|
|
||||||
height *= 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(width,height);
|
|
||||||
ronin.render.context().drawImage(img, 0,0,width * 2,height * 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
function Query(query_str)
|
function Query(query_str = "")
|
||||||
{
|
{
|
||||||
this.module = query_str.split(" ")[0];
|
this.module = query_str.split(" ")[0];
|
||||||
var parts = query_str.split(" ").splice(1);
|
var parts = query_str.split(" ").splice(1);
|
||||||
@ -9,16 +9,19 @@ function Query(query_str)
|
|||||||
|
|
||||||
for(part_id in parts){
|
for(part_id in parts){
|
||||||
var part = parts[part_id];
|
var part = parts[part_id];
|
||||||
|
// Method
|
||||||
if(part.indexOf(":") > -1){
|
if(part.indexOf(":") > -1){
|
||||||
var key = part.indexOf(":") > -1 ? part.split(":")[0] : "any";
|
var key = part.indexOf(":") > -1 ? part.split(":")[0] : "any";
|
||||||
var value = part.indexOf(":") > -1 ? part.split(":")[1] : part;
|
var value = part.indexOf(":") > -1 ? part.split(":")[1] : part;
|
||||||
this.methods[key] = parse_parameters(value);
|
this.methods[key] = parse_parameters(value);
|
||||||
}
|
}
|
||||||
|
// Setting
|
||||||
else if(part.indexOf("=") > -1){
|
else if(part.indexOf("=") > -1){
|
||||||
var key = part.indexOf("=") > -1 ? part.split("=")[0] : "any";
|
var key = part.indexOf("=") > -1 ? part.split("=")[0] : "any";
|
||||||
var value = part.indexOf("=") > -1 ? part.split("=")[1] : part;
|
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){
|
else if(part.indexOf("->") > -1){
|
||||||
var key = part.indexOf("->") > -1 ? part.split("->")[0] : "any";
|
var key = part.indexOf("->") > -1 ? part.split("->")[0] : "any";
|
||||||
var value = part.indexOf("->") > -1 ? part.split("->")[1] : part;
|
var value = part.indexOf("->") > -1 ? part.split("->")[1] : part;
|
||||||
@ -28,6 +31,7 @@ function Query(query_str)
|
|||||||
|
|
||||||
function parse_parameters(param_str)
|
function parse_parameters(param_str)
|
||||||
{
|
{
|
||||||
|
// Modifier
|
||||||
if(param_str.indexOf(">>") > -1){
|
if(param_str.indexOf(">>") > -1){
|
||||||
return parse_modifier(param_str);
|
return parse_modifier(param_str);
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,6 @@ function Ronin()
|
|||||||
this.grid.update();
|
this.grid.update();
|
||||||
this.guide.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=$";
|
||||||
}
|
}
|
||||||
}
|
}
|
4
sources/scripts/units/rect.js
Normal file
4
sources/scripts/units/rect.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
function Rect(rect_str)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user