diff --git a/build/litegraph.js b/build/litegraph.js
index f798b977bb..1d77ad393f 100644
--- a/build/litegraph.js
+++ b/build/litegraph.js
@@ -482,7 +482,7 @@
},
registerSearchboxExtra: function(node_type, description, data) {
- this.searchbox_extras[description] = {
+ this.searchbox_extras[description.toLowerCase()] = {
type: node_type,
desc: description,
data: data
@@ -9111,7 +9111,7 @@ LGraphNode.prototype.executeAction = function(action)
if (that.onSearchBoxSelection) {
that.onSearchBoxSelection(name, event, graphcanvas);
} else {
- var extra = LiteGraph.searchbox_extras[name];
+ var extra = LiteGraph.searchbox_extras[name.toLowerCase()];
if (extra) {
name = extra.type;
}
@@ -9127,10 +9127,7 @@ LGraphNode.prototype.executeAction = function(action)
if (extra && extra.data) {
if (extra.data.properties) {
for (var i in extra.data.properties) {
- node.addProperty(
- extra.data.properties[i][0],
- extra.data.properties[i][0]
- );
+ node.addProperty( i, extra.data.properties[i] );
}
}
if (extra.data.inputs) {
@@ -11327,8 +11324,8 @@ if (typeof exports != "undefined") {
NodeScript.prototype.compileCode = function(code) {
this._func = null;
- if (code.length > 100) {
- console.warn("Script too long, max 100 chars");
+ if (code.length > 256) {
+ console.warn("Script too long, max 256 chars");
} else {
var code_low = code.toLowerCase();
var forbidden_words = [
@@ -13361,9 +13358,9 @@ if (typeof exports != "undefined") {
this.addProperty("OP", "+", "enum", { values: MathOperation.values });
}
- MathOperation.values = ["+", "-", "*", "/", "%", "^"];
+ MathOperation.values = ["+", "-", "*", "/", "%", "^", "max", "min"];
- MathOperation.title = "Operation";
+ MathOperation.title = "Operation";
MathOperation.desc = "Easy math operators";
MathOperation["@OP"] = {
type: "enum",
@@ -13373,6 +13370,8 @@ if (typeof exports != "undefined") {
MathOperation.size = [100, 60];
MathOperation.prototype.getTitle = function() {
+ if(this.properties.OP == "max" || this.properties.OP == "min")
+ return this.properties.OP + "(A,B)";
return "A " + this.properties.OP + " B";
};
@@ -13420,6 +13419,12 @@ if (typeof exports != "undefined") {
case "^":
result = Math.pow(A, B);
break;
+ case "max":
+ result = Math.max(A, B);
+ break;
+ case "min":
+ result = Math.min(A, B);
+ break;
default:
console.warn("Unknown operation: " + this.properties.OP);
}
@@ -13444,6 +13449,16 @@ if (typeof exports != "undefined") {
LiteGraph.registerNodeType("math/operation", MathOperation);
+ LiteGraph.registerSearchboxExtra("math/operation", "MAX", {
+ properties: {OP:"max"},
+ title: "MAX()"
+ });
+
+ LiteGraph.registerSearchboxExtra("math/operation", "MIN", {
+ properties: {OP:"min"},
+ title: "MIN()"
+ });
+
//Math compare
function MathCompare() {
this.addInput("A", "number");
@@ -13641,7 +13656,7 @@ if (typeof exports != "undefined") {
MathTrigonometry.title = "Trigonometry";
MathTrigonometry.desc = "Sin Cos Tan";
- MathTrigonometry.filter = "shader";
+ //MathTrigonometry.filter = "shader";
MathTrigonometry.prototype.onExecute = function() {
var v = this.getInputData(0);
@@ -16117,8 +16132,7 @@ if (typeof exports != "undefined") {
this.addInput("TextureB", "Texture");
this.addInput("value", "number");
this.addOutput("Texture", "Texture");
- this.help =
- "
pixelcode must be vec3, uvcode must be vec2, is optional
\
+ this.help = "pixelcode must be vec3, uvcode must be vec2, is optional
\
uv: tex. coords
color: texture colorB: textureB
time: scene time value: input value
For multiline you must type: result = ...
";
this.properties = {
@@ -16248,7 +16262,8 @@ if (typeof exports != "undefined") {
shader = new GL.Shader( Shader.SCREEN_VERTEX_SHADER, final_pixel_code );
this.boxcolor = "#00FF00";
} catch (err) {
- console.log("Error compiling shader: ", err, final_pixel_code );
+ //console.log("Error compiling shader: ", err, final_pixel_code );
+ GL.Shader.dumpErrorToConsole(err,Shader.SCREEN_VERTEX_SHADER, final_pixel_code);
this.boxcolor = "#FF0000";
this.has_error = true;
return;
@@ -16257,6 +16272,9 @@ if (typeof exports != "undefined") {
this._shader_code = uvcode + "|" + pixelcode;
}
+ if(!this._shader)
+ return;
+
var value = this.getInputData(2);
if (value != null) {
this.properties.value = value;
@@ -16323,14 +16341,16 @@ if (typeof exports != "undefined") {
this.addOutput("out", "Texture");
this.properties = {
code: "",
+ u_value: 1,
+ u_color: [1,1,1,1],
width: 512,
height: 512,
precision: LGraphTexture.DEFAULT
};
this.properties.code =
- "\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n//your code here\n\ngl_FragColor = vec4(color, 1.0);\n}\n";
- this._uniforms = { in_texture: 0, texSize: vec2.create(), time: 0 };
+ "//time: time in seconds\n//texSize: vec2 with res\nuniform float u_value;\nuniform vec4 u_color;\n\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n //your code here\n color.xy=uv;\n\ngl_FragColor = vec4(color, 1.0);\n}\n";
+ this._uniforms = { u_value: 1, u_color: vec4.create(), in_texture: 0, texSize: vec2.create(), time: 0 };
}
LGraphTextureShader.title = "Shader";
@@ -16466,6 +16486,7 @@ if (typeof exports != "undefined") {
var in_tex = null;
//set uniforms
+ if(this.inputs)
for (var i = 0; i < this.inputs.length; ++i) {
var info = this.getInputInfo(i);
var data = this.getInputData(i);
@@ -16485,10 +16506,7 @@ if (typeof exports != "undefined") {
}
var uniforms = this._uniforms;
- var type = LGraphTexture.getTextureType(
- this.properties.precision,
- in_tex
- );
+ var type = LGraphTexture.getTextureType( this.properties.precision, in_tex );
//render to texture
var w = this.properties.width | 0;
@@ -16502,18 +16520,11 @@ if (typeof exports != "undefined") {
uniforms.texSize[0] = w;
uniforms.texSize[1] = h;
uniforms.time = this.graph.getTime();
+ uniforms.u_value = this.properties.u_value;
+ uniforms.u_color.set( this.properties.u_color );
- if (
- !this._tex ||
- this._tex.type != type ||
- this._tex.width != w ||
- this._tex.height != h
- ) {
- this._tex = new GL.Texture(w, h, {
- type: type,
- format: gl.RGBA,
- filter: gl.LINEAR
- });
+ if ( !this._tex || this._tex.type != type || this._tex.width != w || this._tex.height != h ) {
+ this._tex = new GL.Texture(w, h, { type: type, format: gl.RGBA, filter: gl.LINEAR });
}
var tex = this._tex;
tex.drawTo(function() {
@@ -16567,10 +16578,7 @@ if (typeof exports != "undefined") {
var width = tex.width;
var height = tex.height;
- var type =
- this.precision === LGraphTexture.LOW
- ? gl.UNSIGNED_BYTE
- : gl.HIGH_PRECISION_FORMAT;
+ var type = this.precision === LGraphTexture.LOW ? gl.UNSIGNED_BYTE : gl.HIGH_PRECISION_FORMAT;
if (this.precision === LGraphTexture.DEFAULT) {
type = tex.type;
}
@@ -20034,6 +20042,7 @@ if (typeof exports != "undefined") {
code: "",
width: 512,
height: 512,
+ clear: true,
precision: LGraphTexture.DEFAULT
};
this._func = null;
@@ -20041,8 +20050,8 @@ if (typeof exports != "undefined") {
}
LGraphTextureCanvas2D.title = "Canvas2D";
- LGraphTextureCanvas2D.desc =
- "Executes Canvas2D code inside a texture or the viewport";
+ LGraphTextureCanvas2D.desc = "Executes Canvas2D code inside a texture or the viewport.";
+ LGraphTextureCanvas2D.help = "Set width and height to 0 to match viewport size.";
LGraphTextureCanvas2D.widgets_info = {
precision: { widget: "combo", values: LGraphTexture.MODE_VALUES },
@@ -20058,13 +20067,7 @@ if (typeof exports != "undefined") {
if (name == "code" && LiteGraph.allow_scripts) {
this._func = null;
try {
- this._func = new Function(
- "canvas",
- "ctx",
- "time",
- "script",
- value
- );
+ this._func = new Function( "canvas", "ctx", "time", "script", value );
this.boxcolor = "#00FF00";
} catch (err) {
this.boxcolor = "#FF0000";
@@ -20090,17 +20093,26 @@ if (typeof exports != "undefined") {
var width = this.properties.width || gl.canvas.width;
var height = this.properties.height || gl.canvas.height;
var temp = this._temp_texture;
- if (!temp || temp.width != width || temp.height != height) {
+ var type = LGraphTexture.getTextureType( this.properties.precision );
+ if (!temp || temp.width != width || temp.height != height || temp.type != type ) {
temp = this._temp_texture = new GL.Texture(width, height, {
format: gl.RGBA,
- filter: gl.LINEAR
+ filter: gl.LINEAR,
+ type: type
});
}
+ var properties = this.properties;
var that = this;
var time = this.graph.getTime();
temp.drawTo(function() {
gl.start2D();
+ if(properties.clear)
+ {
+ gl.clearColor(0,0,0,0);
+ gl.clear( gl.COLOR_BUFFER_BIT );
+ }
+
try {
if (func.draw) {
func.draw.call(that, gl.canvas, gl, time, func);
@@ -20121,6 +20133,8 @@ if (typeof exports != "undefined") {
LiteGraph.registerNodeType("texture/canvas2D", LGraphTextureCanvas2D);
+ // To do chroma keying *****************
+
function LGraphTextureMatte() {
this.addInput("in", "Texture");
diff --git a/build/litegraph.min.js b/build/litegraph.min.js
index a61110935f..2abf065f89 100755
--- a/build/litegraph.min.js
+++ b/build/litegraph.min.js
@@ -1,4 +1,4 @@
-(function(v){function d(a){c.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function h(a,b,e,s,l,c){this.id=a;this.type=b;this.origin_id=e;this.origin_slot=s;this.target_id=l;this.target_slot=c;this._data=null;this._pos=new Float32Array(2)}function p(a){this._ctor(a)}function n(a){this._ctor(a)}function t(a,b){this.offset=new Float32Array([0,0]);this.scale=1;this.max_scale=10;this.min_scale=0.1;this.onredraw=null;this.enabled=!0;this.last_mouse=
+(function(v){function d(a){c.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function h(a,b,e,s,l,c){this.id=a;this.type=b;this.origin_id=e;this.origin_slot=s;this.target_id=l;this.target_slot=c;this._data=null;this._pos=new Float32Array(2)}function q(a){this._ctor(a)}function n(a){this._ctor(a)}function t(a,b){this.offset=new Float32Array([0,0]);this.scale=1;this.max_scale=10;this.min_scale=0.1;this.onredraw=null;this.enabled=!0;this.last_mouse=
[0,0];this.element=null;this.visible_area=new Float32Array(4);a&&(this.element=a,b||this.bindEvents(a))}function f(a,b,e){e=e||{};this.background_image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=";
a&&a.constructor===String&&(a=document.querySelector(a));this.ds=new t;this.zoom_modify_alpha=!0;this.title_text_font=""+c.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+c.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=c.NODE_TITLE_COLOR;this.default_link_color=c.LINK_COLOR;this.default_connection_color={input_off:"#778",input_on:"#7F7",output_off:"#778",output_on:"#7F7"};this.highquality_render=!0;this.use_gradients=!1;this.editor_alpha=1;this.pause_rendering=!1;this.clear_background=
!0;this.read_only=!1;this.render_only_selected=!0;this.live_mode=!1;this.allow_searchbox=this.allow_interaction=this.allow_dragnodes=this.allow_dragcanvas=this.show_info=!0;this.drag_mode=this.allow_reconnect_links=!1;this.filter=this.dragging_rectangle=null;this.always_render_background=!1;this.render_canvas_border=this.render_shadows=!0;this.render_connections_shadows=!1;this.render_connections_border=!0;this.render_connection_arrows=this.render_curved_connections=!1;this.render_collapsed_slots=
@@ -10,122 +10,122 @@ e,!0);this.root=l;if(b.title){var c=document.createElement("div");c.className="l
clearTimeout(l.closing_timer)});g=document;b.event&&(g=b.event.target.ownerDocument);g||(g=document);g.body.appendChild(l);c=b.left||0;g=b.top||0;if(b.event){c=b.event.clientX-10;g=b.event.clientY-10;b.title&&(g-=20);b.parentMenu&&(c=b.parentMenu.root.getBoundingClientRect(),c=c.left+c.width);var d=document.body.getBoundingClientRect(),f=l.getBoundingClientRect();c>d.width-f.width-10&&(c=d.width-f.width-10);g>d.height-f.height-10&&(g=d.height-f.height-10)}l.style.left=c+"px";l.style.top=g+"px";b.scale&&
(l.style.transform="scale("+b.scale+")")}var c=v.LiteGraph={VERSION:0.4,CANVAS_GRID_SIZE:10,NODE_TITLE_HEIGHT:30,NODE_TITLE_TEXT_Y:20,NODE_SLOT_HEIGHT:20,NODE_WIDGET_HEIGHT:20,NODE_WIDTH:140,NODE_MIN_WIDTH:50,NODE_COLLAPSED_RADIUS:10,NODE_COLLAPSED_WIDTH:80,NODE_TITLE_COLOR:"#999",NODE_TEXT_SIZE:14,NODE_TEXT_COLOR:"#AAA",NODE_SUBTEXT_SIZE:12,NODE_DEFAULT_COLOR:"#333",NODE_DEFAULT_BGCOLOR:"#353535",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",DEFAULT_GROUP_FONT:24,
LINK_COLOR:"#9A9",EVENT_LINK_COLOR:"#A86",CONNECTING_LINK_COLOR:"#AFA",MAX_NUMBER_OF_NODES:1E3,DEFAULT_POSITION:[100,100],VALID_SHAPES:["default","box","round","card"],BOX_SHAPE:1,ROUND_SHAPE:2,CIRCLE_SHAPE:3,CARD_SHAPE:4,ARROW_SHAPE:5,INPUT:1,OUTPUT:2,EVENT:-1,ACTION:-1,ALWAYS:0,ON_EVENT:1,NEVER:2,ON_TRIGGER:3,UP:1,DOWN:2,LEFT:3,RIGHT:4,CENTER:5,STRAIGHT_LINK:0,LINEAR_LINK:1,SPLINE_LINK:2,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,catch_exceptions:!0,
-throw_errors:!0,allow_scripts:!1,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},searchbox_extras:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype";b.type=a;c.debug&&console.log("Node registered: "+a);a.split("/");var e=b.name,s=a.lastIndexOf("/");b.category=a.substr(0,s);b.title||(b.title=e);if(b.prototype)for(var l in p.prototype)b.prototype[l]||(b.prototype[l]=p.prototype[l]);Object.defineProperty(b.prototype,
+throw_errors:!0,allow_scripts:!1,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},searchbox_extras:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype";b.type=a;c.debug&&console.log("Node registered: "+a);a.split("/");var e=b.name,s=a.lastIndexOf("/");b.category=a.substr(0,s);b.title||(b.title=e);if(b.prototype)for(var l in q.prototype)b.prototype[l]||(b.prototype[l]=q.prototype[l]);Object.defineProperty(b.prototype,
"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=c.BOX_SHAPE;break;case "round":this._shape=c.ROUND_SHAPE;break;case "circle":this._shape=c.CIRCLE_SHAPE;break;case "card":this._shape=c.CARD_SHAPE;break;default:this._shape=a}},get:function(a){return this._shape},enumerable:!0});s=this.registered_node_types[a];this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[e]=b);if(c.onNodeTypeRegistered)c.onNodeTypeRegistered(a,b);if(s&&c.onNodeTypeReplaced)c.onNodeTypeReplaced(a,
b,s);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end");if(b.supported_extensions)for(l in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[l].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,e,s,l){for(var g=Array(b.length),d="",f=c.getParameterNames(b),k=0;kd&&(d=c.size[0]),f+=c.size[1]+a;b+=d+a}this.setDirtyCanvas(!0,!0)};d.prototype.getTime=function(){return this.globaltime};d.prototype.getFixedTime=function(){return this.fixedtime};d.prototype.getElapsedTime=function(){return this.elapsed_time};d.prototype.sendEventToAllNodes=function(a,b,e){e=e||c.ALWAYS;var s=this._nodes_in_order?this._nodes_in_order:this._nodes;if(s)for(var l=0,g=s.length;l=c.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";null==a.id||-1==a.id?a.id=++this.last_node_id:this.last_node_ida.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};p.prototype.configure=function(a){this.graph&&this.graph._version++;
-for(var b in a)if("properties"==b)for(var e in a.properties){if(this.properties[e]=a.properties[e],this.onPropertyChanged)this.onPropertyChanged(e,a.properties[e])}else null!=a[b]&&("object"==typeof a[b]?this[b]&&this[b].configure?this[b].configure(a[b]):this[b]=c.cloneObject(a[b],this[b]):this[b]=a[b]);a.title||(this.title=this.constructor.title);if(this.onConnectionsChange){if(this.inputs)for(e=0;e=this.outputs.length)){var e=this.outputs[a];if(e&&(e._data=b,this.outputs[a].links))for(e=0;e=this.outputs.length)){var e=this.outputs[a];if(e&&(e.type=b,this.outputs[a].links))for(e=0;e=this.inputs.length||
-null==this.inputs[a].link)){var e=this.graph.links[this.inputs[a].link];if(!e)return null;if(!b)return e.data;var c=this.graph.getNodeById(e.origin_id);if(!c)return e.data;if(c.updateOutputData)c.updateOutputData(e.origin_slot);else if(c.onExecute)c.onExecute();return e.data}};p.prototype.getInputDataType=function(a){if(!this.inputs||a>=this.inputs.length||null==this.inputs[a].link)return null;a=this.graph.links[this.inputs[a].link];if(!a)return null;var b=this.graph.getNodeById(a.origin_id);return b?
-(a=b.outputs[a.origin_slot])?a.type:null:a.type};p.prototype.getInputDataByName=function(a,b){var e=this.findInputSlot(a);return-1==e?null:this.getInputData(e,b)};p.prototype.isInputConnected=function(a){return this.inputs?a=this.inputs.length)return null;a=this.inputs[a];return a&&null!==a.link?
-(a=this.graph.links[a.link])?this.graph.getNodeById(a.origin_id):null:null};p.prototype.getInputOrProperty=function(a){if(!this.inputs||!this.inputs.length)return this.properties?this.properties[a]:null;for(var b=0,e=this.inputs.length;b=this.outputs.length?null:this.outputs[a]._data};p.prototype.getOutputInfo=function(a){return this.outputs?
-a=this.outputs.length)return null;a=this.outputs[a];
-if(!a.links||0==a.links.length)return null;for(var b=[],e=0;ea&&this.pos[1]-l-eb)return!0;return!1};p.prototype.getSlotInPosition=function(a,b){var e=new Float32Array(2);if(this.inputs)for(var c=0,l=this.inputs.length;c=this.outputs.length)return c.debug&&console.log("Connect: Error, slot number not found"),null;b&&b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"target node is null";if(b==
-this)return null;if(e.constructor===String){if(e=b.findInputSlot(e),-1==e)return c.debug&&console.log("Connect: Error, no slot of name "+e),null}else{if(e===c.EVENT)return null;if(!b.inputs||e>=b.inputs.length)return c.debug&&console.log("Connect: Error, slot number not found"),null}null!=b.inputs[e].link&&b.disconnectInput(e);var s=this.outputs[a];if(b.onConnectInput&&!1===b.onConnectInput(e,s.type,s))return null;var l=b.inputs[e],g=null;if(c.isValidConnection(s.type,l.type)){g=new h(this.graph.last_link_id++,
-l.type,this.id,a,b.id,e);this.graph.links[g.id]=g;null==s.links&&(s.links=[]);s.links.push(g.id);b.inputs[e].link=g.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(c.OUTPUT,a,!0,g,s);if(b.onConnectionsChange)b.onConnectionsChange(c.INPUT,e,!0,g,l);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(c.INPUT,b,e,this,a),this.graph.onNodeConnectionChange(c.OUTPUT,this,a,b,e))}this.setDirtyCanvas(!1,!0);this.graph.connectionChange(this,
-g);return g};p.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return c.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return c.debug&&console.log("Connect: Error, slot number not found"),!1;var e=this.outputs[a];if(!e||!e.links||0==e.links.length)return!1;if(b){b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var s=0,l=e.links.length;s=this.inputs.length)return c.debug&&console.log("Connect: Error, slot number not found"),
-!1;var b=this.inputs[a];if(!b)return!1;var e=this.inputs[a].link;this.inputs[a].link=null;var s=this.graph.links[e];if(s){var l=this.graph.getNodeById(s.origin_id);if(!l)return!1;var g=l.outputs[s.origin_slot];if(!g||!g.links||0==g.links.length)return!1;for(var d=0,f=g.links.length;db&&this.inputs[b].pos)return e[0]=this.pos[0]+this.inputs[b].pos[0],e[1]=this.pos[1]+this.inputs[b].pos[1],e;if(!a&&s>b&&this.outputs[b].pos)return e[0]=this.pos[0]+this.outputs[b].pos[0],e[1]=this.pos[1]+this.outputs[b].pos[1],e;if(this.horizontal)return e[0]=
-this.pos[0]+this.size[0]/s*(b+0.5),e[1]=a?this.pos[1]-c.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],e;e[0]=a?this.pos[0]+l:this.pos[0]+this.size[0]+1-l;e[1]=this.pos[1]+(b+0.7)*c.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return e};p.prototype.alignToGrid=function(){this.pos[0]=c.CANVAS_GRID_SIZE*Math.round(this.pos[0]/c.CANVAS_GRID_SIZE);this.pos[1]=c.CANVAS_GRID_SIZE*Math.round(this.pos[1]/c.CANVAS_GRID_SIZE)};p.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);
-this.console.length>p.MAX_CONSOLE&&this.console.shift();this.graph.onNodeTrace(this,a)};p.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};p.prototype.loadImage=function(a){var b=new Image;b.src=c.node_images_path+a;b.ready=!1;var e=this;b.onload=function(){this.ready=!0;e.setDirtyCanvas(!0)};return b};p.prototype.captureInput=function(a){if(this.graph&&this.graph.list_of_graphcanvas)for(var b=this.graph.list_of_graphcanvas,e=0;ea.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});Object.defineProperty(this,"size",{set:function(a){!a||
-2>a.length||(this._size[0]=Math.max(140,a[0]),this._size[1]=Math.max(80,a[1]))},get:function(){return this._size},enumerable:!0})};n.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font=a.font};n.prototype.serialize=function(){var a=this._bounding;return{title:this.title,bounding:[Math.round(a[0]),Math.round(a[1]),Math.round(a[2]),Math.round(a[3])],color:this.color,font:this.font}};n.prototype.move=function(a,b,e){this._pos[0]+=a;this._pos[1]+=
-b;if(!e)for(e=0;ethis.max_scale&&(a=this.max_scale);if(a!=this.scale&&this.element){var e=this.element.getBoundingClientRect();if(e){b=b||[0.5*e.width,0.5*e.height];
-e=this.convertCanvasToOffset(b);this.scale=a;0.01>Math.abs(this.scale-1)&&(this.scale=1);var c=this.convertCanvasToOffset(b),e=[c[0]-e[0],c[1]-e[1]];this.offset[0]+=e[0];this.offset[1]+=e[1];if(this.onredraw)this.onredraw(this)}}};t.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};t.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};v.LGraphCanvas=c.LGraphCanvas=f;f.link_type_colors={"-1":c.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};f.gradients={};
-f.prototype.clear=function(){this.fps=this.render_time=this.last_draw_time=this.frame=0;this.dragging_rectangle=null;this.selected_nodes={};this.selected_group=null;this.visible_nodes=[];this.connecting_node=this.node_capturing_input=this.node_over=this.node_dragged=null;this.highlighted_links={};this.dirty_bgcanvas=this.dirty_canvas=!0;this.node_widget=this.node_in_panel=this.dirty_area=null;this.last_mouse=[0,0];this.last_mouseclick=0;this.visible_area.set([0,0,0,0]);if(this.onClear)this.onClear()};
-f.prototype.setGraph=function(a,b){this.graph!=a&&(b||this.clear(),!a&&this.graph?this.graph.detachCanvas(this):(a.attachCanvas(this),this.setDirty(!0,!0)))};f.prototype.openSubgraph=function(a){if(!a)throw"graph cannot be null";if(this.graph==a)throw"graph cannot be the same";this.clear();this.graph&&(this._graph_stack||(this._graph_stack=[]),this._graph_stack.push(this.graph));a.attachCanvas(this);this.setDirty(!0,!0)};f.prototype.closeSubgraph=function(){if(this._graph_stack&&0!=this._graph_stack.length){var a=
-this.graph._subgraph_node,b=this._graph_stack.pop();this.selected_nodes={};this.highlighted_links={};b.attachCanvas(this);this.setDirty(!0,!0);a&&(this.centerOnNode(a),this.selectNodes([a]))}};f.prototype.getCurrentGraph=function(){return this.graph};f.prototype.setCanvas=function(a,b){if(a&&a.constructor===String&&(a=document.getElementById(a),!a))throw"Error creating LiteGraph canvas: Canvas not found";if(a!==this.canvas&&(!a&&this.canvas&&(b||this.unbindEvents()),this.canvas=a,this.ds.element=
-a)){a.className+=" lgraphcanvas";a.data=this;a.tabindex="1";this.bgcanvas=null;this.bgcanvas||(this.bgcanvas=document.createElement("canvas"),this.bgcanvas.width=this.canvas.width,this.bgcanvas.height=this.canvas.height);if(null==a.getContext){if("canvas"!=a.localName)throw"Element supplied for LGraphCanvas must be a