diff --git a/build/litegraph.js b/build/litegraph.js index 54f921b45..77c3a04dd 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -43,6 +43,7 @@ var LiteGraph = global.LiteGraph = { NODE_DEFAULT_BGCOLOR: "#444", NODE_DEFAULT_BOXCOLOR: "#666", NODE_DEFAULT_SHAPE: "box", + DEFAULT_SHADOW_COLOR: "rgba(0,0,0,0.5)", LINK_COLOR: "#AAD", EVENT_LINK_COLOR: "#F85", @@ -5250,16 +5251,12 @@ LGraphCanvas.prototype.drawNode = function(node, ctx ) return; } - //custom draw collapsed method - if(node.flags.collapsed && node.onDrawCollaped && node.onDrawCollapsed(ctx, this) == true) - return; - var editor_alpha = this.editor_alpha; ctx.globalAlpha = editor_alpha; if(this.render_shadows) { - ctx.shadowColor = "rgba(0,0,0,0.5)"; + ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR; ctx.shadowOffsetX = 2 * this.scale; ctx.shadowOffsetY = 2 * this.scale; ctx.shadowBlur = 3 * this.scale; @@ -5267,6 +5264,10 @@ LGraphCanvas.prototype.drawNode = function(node, ctx ) else ctx.shadowColor = "transparent"; + //custom draw collapsed method (draw after shadows because they are affected) + if(node.flags.collapsed && node.onDrawCollaped && node.onDrawCollapsed(ctx, this) == true) + return; + //clip if required (mask) var shape = node._shape || LiteGraph.BOX_SHAPE; var size = temp_vec2; @@ -5564,6 +5565,9 @@ LGraphCanvas.prototype.drawNodeShape = function( node, ctx, size, fgcolor, bgcol //title bar if(title_mode != LiteGraph.TRANSPARENT_TITLE) //!node.flags.collapsed) { + if(node.flags.collapsed) + ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR; + //* gradient test if(this.use_gradients) { @@ -5593,15 +5597,7 @@ LGraphCanvas.prototype.drawNodeShape = function( node, ctx, size, fgcolor, bgcol ctx.roundRect(0,-title_height,size[0]+1, title_height, this.round_radius, node.flags.collapsed ? this.round_radius : 0); ctx.fill(); } - - /* - else if (shape == LiteGraph.CIRCLE_SHAPE) - { - ctx.beginPath(); - ctx.arc(title_height *0.5, title_height * -0.5, (title_height - 6) *0.5,0,Math.PI*2); - ctx.fill(); - } - */ + ctx.shadowColor = "transparent"; } //title box @@ -6026,7 +6022,8 @@ LGraphCanvas.prototype.drawNodeWidgets = function( node, posY, ctx, active_widge ctx.fill(); ctx.stroke(); ctx.fillStyle = "#999"; - ctx.fillText( w.title || "Value", 20, y + H*0.7 ); + if(w.name != null) + ctx.fillText( w.name, 20, y + H*0.7 ); ctx.fillStyle = "#DDD"; ctx.textAlign = "right"; ctx.fillText( w.value, width - 20, y + H*0.7 ); diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 379e7d0bc..0e7173f39 100755 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -6,8 +6,8 @@ a[1]>e||fk.width-g.width-10&&(l=k.width-g.width-10);n>k.height-g.height-10&&(n=k.height-g.height-10)}e.style.left=l+"px";e.style.top=n+"px"}var k=t.LiteGraph={CANVAS_GRID_SIZE:10, -NODE_TITLE_HEIGHT:20,NODE_SLOT_HEIGHT:15,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:"#444",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",LINK_COLOR:"#AAD",EVENT_LINK_COLOR:"#F85",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,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,throw_errors:!0,allow_scripts:!0,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype"; +NODE_TITLE_HEIGHT:20,NODE_SLOT_HEIGHT:15,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:"#444",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",LINK_COLOR:"#AAD",EVENT_LINK_COLOR:"#F85",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,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,throw_errors:!0,allow_scripts:!0,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype"; b.type=a;k.debug&&console.log("Node registered: "+a);a.split("/");var f=b.name,c=a.lastIndexOf("/");b.category=a.substr(0,c);b.title||(b.title=f);if(b.prototype)for(var e in d.prototype)b.prototype[e]||(b.prototype[e]=d.prototype[e]);Object.defineProperty(b.prototype,"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=k.BOX_SHAPE;break;case "round":this._shape=k.ROUND_SHAPE;break;case "circle":this._shape=k.CIRCLE_SHAPE;break;case "card":this._shape=k.CARD_SHAPE; break;default:this._shape=a}},get:function(a){return this._shape},enumerable:!0});this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[f]=b);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(e in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[e].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,f,c){for(var e=Array(b.length), l="",n=k.getParameterNames(b),g=0;gthis.scale?(b.beginPath(),b.rect(0,n,q,p),b.fill()):d==k.ROUND_SHAPE||d==k.CARD_SHAPE?(b.beginPath(),b.roundRect(0,n,q,p,this.round_radius,d==k.CARD_SHAPE?0:this.round_radius),b.fill()):d==k.CIRCLE_SHAPE&&(b.beginPath(),b.arc(0.5*c[0],0.5*c[1],0.5*c[0],0,2*Math.PI),b.fill()));b.shadowColor="transparent"; -a.bgImage&&a.bgImage.width&&b.drawImage(a.bgImage,0.5*(c[0]-a.bgImage.width),0.5*(c[1]-a.bgImage.height));a.bgImageUrl&&!a.bgImage&&(a.bgImage=a.loadImage(a.bgImageUrl));a.onDrawBackground&&(a.gui_rects&&(a.gui_rects.length=0),a.onDrawBackground(b,this));if(x||h==k.TRANSPARENT_TITLE){if(h!=k.TRANSPARENT_TITLE){if(this.use_gradients){var r=g.gradients[m];r||(r=g.gradients[m]=b.createLinearGradient(0,0,400,0),r.addColorStop(0,m),r.addColorStop(1,"#000"));b.fillStyle=r}else b.fillStyle=m;r=b.globalAlpha; -b.beginPath();if(d==k.BOX_SHAPE||0.5>this.scale)b.rect(0,-e,c[0]+1,e),b.fill();else if(d==k.ROUND_SHAPE||d==k.CARD_SHAPE)b.roundRect(0,-e,c[0]+1,e,this.round_radius,a.flags.collapsed?this.round_radius:0),b.fill()}d==k.ROUND_SHAPE||d==k.CIRCLE_SHAPE||d==k.CARD_SHAPE?(0.5b-n._last_time){var p=2-0.002*(b-n._last_time),r="rgba(255,255,255, "+p.toFixed(2)+")";this.renderLink(a,h,q,n,!0,p,r,d,m)}}}}}a.globalAlpha=1};g.prototype.renderLink=function(a,b,c,d,e,l,n,m,h){if(this.highquality_render){m=m||k.RIGHT;h=h||k.LEFT;var x=r(b,c);this.render_connections_border&&0.6b[1]?0:Math.PI,a.save(),a.translate(e[0],e[1]),a.rotate(x),a.beginPath(), -a.moveTo(-5,-5),a.lineTo(0,5),a.lineTo(5,-5),a.fill(),a.restore());if(l)for(l=0;5>l;++l)e=(0.001*k.getTime()+0.2*l)%1,e=this.computeConnectionPoint(b,c,e,m,h),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill()}else a.beginPath(),a.moveTo(b[0],b[1]),a.lineTo(c[0],c[1]),a.stroke()};g.prototype.computeConnectionPoint=function(a,b,c,g,e){g=g||k.RIGHT;e=e||k.LEFT;var l=r(a,b),n=[a[0],a[1]],d=[b[0],b[1]];switch(g){case k.LEFT:n[0]+=-0.25*l;break;case k.RIGHT:n[0]+=0.25*l;break;case k.UP:n[1]+=-0.25* -l;break;case k.DOWN:n[1]+=0.25*l}switch(e){case k.LEFT:d[0]+=-0.25*l;break;case k.RIGHT:d[0]+=0.25*l;break;case k.UP:d[1]+=-0.25*l;break;case k.DOWN:d[1]+=0.25*l}g=(1-c)*(1-c)*(1-c);e=3*(1-c)*(1-c)*c;l=3*(1-c)*c*c;c*=c*c;return[g*a[0]+e*n[0]+l*d[0]+c*b[0],g*a[1]+e*n[1]+l*d[1]+c*b[1]]};g.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=0.25;a.textAlign="center";a.strokeStyle="white";a.globalAlpha=0.75;for(var b=this.visible_nodes,c=0;ch.last_y&&lh.options.max&&(h.value=h.options.max)):"mousedown"==c.type&&(c=40>e?-1:e>n-40?1:0,"number"==h.type?(h.value+=0.1*c*(h.options.step||1),null!=h.options.min&&h.valueh.options.max&&(h.value=h.options.max)):c&&(c=h.options.values.indexOf(h.value)+c,c>=h.options.values.length&&(c=0),0>c&&(c=h.options.values.length-1),h.value=h.options.values[c]));h.callback&&setTimeout(function(){this.callback(this.value,d,a,b)}.bind(h),20);this.dirty_canvas=!0;break;case "text":"mousedown"==c.type&&this.prompt("Value",h.value,function(a){this.value=a}.bind(h),c)}return h}}return null};g.prototype.drawGroups=function(a,b){if(this.graph){var c=this.graph._groups; -b.save();b.globalAlpha=0.5;b.font="24px Arial";for(var g=0;gc&&0.01>b.editor_alpha&& -(clearInterval(g),1>c&&(b.live_mode=!0));1"+q+""+a+"",value:q});if(h.length)return new k.ContextMenu(h,{event:c,callback:l,parentMenu:d,allow_html:!0,node:e},b),!1}};g.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};g.onResizeNode=function(a, -b,c,g,e){e&&(e.size=e.computeSize(),e.setDirtyCanvas(!0,!0))};g.onShowTitleEditor=function(a,b,c,d,e){function l(){e.title=h.value;m.parentNode.removeChild(m);e.setDirtyCanvas(!0,!0)}var m=document.createElement("div");m.className="graphdialog";m.innerHTML="Title";var h=m.querySelector("input");h&&(h.value=e.title,h.addEventListener("keydown",function(a){13==a.keyCode&&(l(),a.preventDefault(),a.stopPropagation())})); -a=g.active_canvas.canvas;b=a.getBoundingClientRect();d=c=-20;b&&(c-=b.left,d-=b.top);event?(m.style.left=event.pageX+c+"px",m.style.top=event.pageY+d+"px"):(m.style.left=0.5*a.width+c+"px",m.style.top=0.5*a.height+d+"px");m.querySelector("button").addEventListener("click",l);a.parentNode.appendChild(m)};g.prototype.prompt=function(a,b,c,m){var e=this;a=a||"";var l=document.createElement("div");l.className="graphdialog rounded";l.innerHTML=" "; -l.close=function(){e.prompt_box=null;l.parentNode.removeChild(l)};l.addEventListener("mouseleave",function(a){l.close()});e.prompt_box&&e.prompt_box.close();e.prompt_box=l;l.querySelector(".name").innerText=a;l.querySelector(".value").value=b;var d=l.querySelector("input");d.addEventListener("keydown",function(a){if(27==a.keyCode)l.close();else if(13==a.keyCode)c&&c(this.value),l.close();else return;a.preventDefault();a.stopPropagation()});l.querySelector("button").addEventListener("click",function(a){c&& -c(d.value);e.setDirty(!0);l.close()});a=g.active_canvas.canvas;b=a.getBoundingClientRect();var h=-20,k=-20;b&&(h-=b.left,k-=b.top);m?(l.style.left=m.pageX+h+"px",l.style.top=m.pageY+k+"px"):(l.style.left=0.5*a.width+h+"px",l.style.top=0.5*a.height+k+"px");a.parentNode.appendChild(l);setTimeout(function(){d.focus()},10);return l};g.prototype.showSearchBox=function(a){function b(b){if(b)if(e.onSearchBoxSelection)e.onSearchBoxSelection(b,a,s);else if(b=k.createNode(b))b.pos=s.convertEventToCanvas(a), -s.graph.add(b);l.close()}function c(a){var b=p;p&&p.classList.remove("selected");p?(p=a?p.nextSibling:p.previousSibling)||(p=b):p=a?d.childNodes[0]:d.childNodes[d.childNodes.length];p&&(p.classList.add("selected"),p.scrollIntoView())}function m(){q=null;var a=r.value;h=null;d.innerHTML="";if(a)if(e.onSearchBox)e.onSearchBox(f,a,s);else for(var c in k.registered_node_types)if(-1!=c.indexOf(a)){var f=document.createElement("div");h||(h=c);f.innerText=c;f.className="help-item";f.addEventListener("click", -function(a){b(this.innerText)});d.appendChild(f)}}var e=this,l=document.createElement("div");l.className="graphdialog rounded";l.innerHTML="Search
";l.close=function(){e.search_box=null;l.parentNode.removeChild(l)};l.addEventListener("mouseleave",function(a){l.close()});e.search_box&&e.search_box.close();e.search_box=l;var d=l.querySelector(".helper"),h=null,q=null,p=null,r=l.querySelector("input"); -r&&r.addEventListener("keydown",function(a){if(38==a.keyCode)c(!1);else if(40==a.keyCode)c(!0);else if(27==a.keyCode)l.close();else if(13==a.keyCode)p?b(p.innerHTML):h?b(h):l.close();else{q&&clearInterval(q);q=setTimeout(m,10);return}a.preventDefault();a.stopPropagation()});var s=g.active_canvas,u=s.canvas,t=u.getBoundingClientRect(),z=-20,E=-20;t&&(z-=t.left,E-=t.top);a?(l.style.left=a.pageX+z+"px",l.style.top=a.pageY+E+"px"):(l.style.left=0.5*u.width+z+"px",l.style.top=0.5*u.height+E+"px");u.parentNode.appendChild(l); -setTimeout(function(){r.focus()},10);return l};g.prototype.showEditPropertyValue=function(a,b,c){function g(){e(p.value)}function e(c){"number"==typeof a.properties[b]&&(c=Number(c));"array"==l&&(c=c.split(",").map(Number));a.properties[b]=c;a._graph&&a._graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,c);q.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var l="string";null!==a.properties[b]&&(l=typeof a.properties[b]);"object"==l&&a.properties[b].length&&(l="array"); -var d=null;a.getPropertyInfo&&(d=a.getPropertyInfo(b));if(a.properties_info)for(var m=0;m";else if("enum"==l&&d.values){h=""}else if("boolean"==l)h="";else{console.warn("unknown type: "+l);return}var q=this.createDialog(""+b+""+h+"",c);if("enum"==l&&d.values){var p=q.querySelector("select");p.addEventListener("change",function(a){e(a.target.value)})}else if("boolean"==l)(p=q.querySelector("input"))&&p.addEventListener("click",function(a){e(!!p.checked)}); -else if(p=q.querySelector("input"))p.value=void 0!==a.properties[b]?a.properties[b]:"",p.addEventListener("keydown",function(a){13==a.keyCode&&(g(),a.preventDefault(),a.stopPropagation())});q.querySelector("button").addEventListener("click",g)}};g.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;var g=this.canvas.getBoundingClientRect(),e=-20,l=-20;g&&(e-=g.left,l-=g.top);b.position?(e+=b.position[0],l+=b.position[1]):b.event? -(e+=b.event.pageX,l+=b.event.pageY):(e+=0.5*this.canvas.width,l+=0.5*this.canvas.height);c.style.left=e+"px";c.style.top=l+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};g.onMenuNodeCollapse=function(a,b,c,g,e){e.collapse()};g.onMenuNodePin=function(a,b,c,g,e){e.pin()};g.onMenuNodeMode=function(a,b,c,g,e){new k.ContextMenu(["Always","On Event","On Trigger","Never"],{event:c,callback:function(a){if(e)switch(a){case "On Event":e.mode= -k.ON_EVENT;break;case "On Trigger":e.mode=k.ON_TRIGGER;break;case "Never":e.mode=k.NEVER;break;default:e.mode=k.ALWAYS}},parentMenu:g,node:e});return!1};g.onMenuNodeColors=function(a,b,c,d,e){if(!e)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var l in g.node_colors)a=g.node_colors[l],a={value:l,content:""+l+""},b.push(a);new k.ContextMenu(b,{event:c,callback:function(a){e&&((a=a.value?g.node_colors[a.value]:null)?e.constructor===k.LGraphGroup?e.color=a.groupcolor:(e.color=a.color,e.bgcolor=a.bgcolor):(delete e.color,delete e.bgcolor),e.setDirtyCanvas(!0,!0))},parentMenu:d,node:e});return!1};g.onMenuNodeShapes=function(a,b,c,g,e){if(!e)throw"no node passed";new k.ContextMenu(k.VALID_SHAPES,{event:c,callback:function(a){e&&(e.shape=a,e.setDirtyCanvas(!0))},parentMenu:g,node:e}); -return!1};g.onMenuNodeRemove=function(a,b,c,g,e){if(!e)throw"no node passed";!1!==e.removable&&(e.graph.remove(e),e.setDirtyCanvas(!0,!0))};g.onMenuNodeClone=function(a,b,c,g,e){!1!=e.clonable&&(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.add(a),e.setDirtyCanvas(!0,!0))};g.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"},brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223",bgcolor:"#335",groupcolor:"#88A"}, -pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"},purple:{color:"#323",bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",groupcolor:"#444"}};g.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:g.onMenuAdd},{content:"Add Group",callback:g.onGroupAdd}],this._graph_stack&& -0Name",e),d=m.querySelector("input");m.querySelector("button").addEventListener("click", -function(b){if(d.value){if(b=g.input?a.getInputInfo(g.slot):a.getOutputInfo(g.slot))b.label=d.value;c.setDirty(!0)}m.close()})}},extra:a},m=null;a&&(m=a.getSlotInPosition(b.canvasX,b.canvasY),g.active_node=a);m?(e=[],e.push(m.locked?"Cannot remove":{content:"Remove Slot",slot:m}),e.push({content:"Rename Slot",slot:m}),l.title=(m.input?m.input.type:m.output.type)||"*",m.input&&m.input.type==k.ACTION&&(l.title="Action"),m.output&&m.output.type==k.EVENT&&(l.title="Event")):a?e=this.getNodeMenuOptions(a): -(e=this.getCanvasMenuOptions(),(m=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&e.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:m,options:this.getGroupMenuOptions(m)}}));e&&new k.ContextMenu(e,l,d)};this.CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,g,e,l){void 0===e&&(e=5);void 0===l&&(l=e);this.moveTo(a+e,b);this.lineTo(a+c-e,b);this.quadraticCurveTo(a+c,b,a+c,b+e);this.lineTo(a+c,b+g-l);this.quadraticCurveTo(a+c,b+g,a+c-l, -b+g);this.lineTo(a+l,b+g);this.quadraticCurveTo(a,b+g,a,b+g-l);this.lineTo(a,b+e);this.quadraticCurveTo(a,b,a+e,b)});k.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};k.distance=r;k.colorToString=function(a){return"rgba("+Math.round(255*a[0]).toFixed()+","+Math.round(255*a[1]).toFixed()+","+Math.round(255*a[2]).toFixed()+","+(4==a.length?a[3].toFixed(2):"1.0")+")"};k.isInsideRectangle=p;k.growBounding=function(a,b,c){ba[2]&&(a[2]=b);ca[3]&& -(a[3]=c)};k.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};k.overlapBounding=s;k.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,g,e,l=0;6>l;l+=2)g="0123456789ABCDEF".indexOf(a.charAt(l)),e="0123456789ABCDEF".indexOf(a.charAt(l+1)),b[c]=16*g+e,c++;return b};k.num2hex=function(a){for(var b="#",c,g,e=0;3>e;e++)c=a[e]/16,g=a[e]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(g);return b};u.prototype.addItem= -function(a,b,c){function g(a){var b=this.value;b&&b.has_submenu&&e.call(this,a)}function e(a){var b=this.value,e=!0;l.current_submenu&&l.current_submenu.close(a);if(c.callback){var g=c.callback.call(this,b,c,a,l,c.node);!0===g&&(e=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&!0!==b.disabled&&(g=b.callback.call(this,b,c,a,l,c.extra),!0===g&&(e=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new l.constructor(b.submenu.options,{callback:b.submenu.callback,event:a, -parentMenu:l,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});e=!1}e&&!l.lock&&l.close()}var l=this;c=c||{};var m=document.createElement("div");m.className="litemenu-entry submenu";var d=!1;if(null===b)m.classList.add("separator");else{m.innerHTML=b&&b.title?b.title:a;if(m.value=b)b.disabled&&(d=!0,m.classList.add("disabled")),(b.submenu||b.has_submenu)&&m.classList.add("has_submenu");"function"==typeof b?(m.dataset.value=a,m.onclick_callback= -b):m.dataset.value=b;b.className&&(m.className+=" "+b.className)}this.root.appendChild(m);d||m.addEventListener("click",e);c.autoopen&&m.addEventListener("mouseenter",g);return m};u.prototype.close=function(a,b){this.root.parentNode&&this.root.parentNode.removeChild(this.root);this.parentMenu&&!b&&(this.parentMenu.lock=!1,this.parentMenu.current_submenu=null,void 0===a?this.parentMenu.close():a&&!u.isCursorOverElement(a,this.parentMenu.root)&&u.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&& -this.current_submenu.close(a,!0)};u.trigger=function(a,b,c,g){var e=document.createEvent("CustomEvent");e.initCustomEvent(b,!0,!0,c);e.srcElement=g;a.dispatchEvent?a.dispatchEvent(e):a.__events&&a.__events.dispatchEvent(e);return e};u.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};u.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};u.isCursorOverElement=function(a, -b){var c=a.pageX,g=a.pageY,e=b.getBoundingClientRect();return e?g>e.top&&ge.left&&cthis.scale?(b.beginPath(),b.rect(0,n,q,p),b.fill()):d==k.ROUND_SHAPE||d==k.CARD_SHAPE?(b.beginPath(),b.roundRect(0,n,q,p,this.round_radius,d==k.CARD_SHAPE?0:this.round_radius),b.fill()):d==k.CIRCLE_SHAPE&&(b.beginPath(),b.arc(0.5*c[0],0.5*c[1],0.5*c[0],0,2*Math.PI),b.fill()));b.shadowColor= +"transparent";a.bgImage&&a.bgImage.width&&b.drawImage(a.bgImage,0.5*(c[0]-a.bgImage.width),0.5*(c[1]-a.bgImage.height));a.bgImageUrl&&!a.bgImage&&(a.bgImage=a.loadImage(a.bgImageUrl));a.onDrawBackground&&(a.gui_rects&&(a.gui_rects.length=0),a.onDrawBackground(b,this));if(x||h==k.TRANSPARENT_TITLE){if(h!=k.TRANSPARENT_TITLE){a.flags.collapsed&&(b.shadowColor=k.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var r=g.gradients[m];r||(r=g.gradients[m]=b.createLinearGradient(0,0,400,0),r.addColorStop(0,m), +r.addColorStop(1,"#000"));b.fillStyle=r}else b.fillStyle=m;r=b.globalAlpha;b.beginPath();if(d==k.BOX_SHAPE||0.5>this.scale)b.rect(0,-e,c[0]+1,e),b.fill();else if(d==k.ROUND_SHAPE||d==k.CARD_SHAPE)b.roundRect(0,-e,c[0]+1,e,this.round_radius,a.flags.collapsed?this.round_radius:0),b.fill();b.shadowColor="transparent"}d==k.ROUND_SHAPE||d==k.CIRCLE_SHAPE||d==k.CARD_SHAPE?(0.5b-n._last_time){var p=2-0.002*(b-n._last_time),r="rgba(255,255,255, "+p.toFixed(2)+")";this.renderLink(a,h,q,n,!0,p,r,d,m)}}}}}a.globalAlpha=1};g.prototype.renderLink=function(a,b,c,d,e,l,n,m,h){if(this.highquality_render){m=m||k.RIGHT;h=h||k.LEFT;var x=r(b,c);this.render_connections_border&&0.6b[1]?0:Math.PI,a.save(),a.translate(e[0],e[1]),a.rotate(x),a.beginPath(),a.moveTo(-5,-5),a.lineTo(0,5),a.lineTo(5,-5),a.fill(),a.restore());if(l)for(l=0;5>l;++l)e=(0.001*k.getTime()+0.2*l)%1,e=this.computeConnectionPoint(b,c,e,m,h),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill()}else a.beginPath(),a.moveTo(b[0],b[1]),a.lineTo(c[0],c[1]),a.stroke()};g.prototype.computeConnectionPoint=function(a,b,c,g,e){g=g||k.RIGHT;e=e||k.LEFT;var l=r(a,b),n=[a[0],a[1]], +d=[b[0],b[1]];switch(g){case k.LEFT:n[0]+=-0.25*l;break;case k.RIGHT:n[0]+=0.25*l;break;case k.UP:n[1]+=-0.25*l;break;case k.DOWN:n[1]+=0.25*l}switch(e){case k.LEFT:d[0]+=-0.25*l;break;case k.RIGHT:d[0]+=0.25*l;break;case k.UP:d[1]+=-0.25*l;break;case k.DOWN:d[1]+=0.25*l}g=(1-c)*(1-c)*(1-c);e=3*(1-c)*(1-c)*c;l=3*(1-c)*c*c;c*=c*c;return[g*a[0]+e*n[0]+l*d[0]+c*b[0],g*a[1]+e*n[1]+l*d[1]+c*b[1]]};g.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=0.25;a.textAlign="center"; +a.strokeStyle="white";a.globalAlpha=0.75;for(var b=this.visible_nodes,c=0;ch.last_y&&lh.options.max&&(h.value=h.options.max)):"mousedown"==c.type&&(c=40>e?-1:e>n-40?1:0,"number"== +h.type?(h.value+=0.1*c*(h.options.step||1),null!=h.options.min&&h.valueh.options.max&&(h.value=h.options.max)):c&&(c=h.options.values.indexOf(h.value)+c,c>=h.options.values.length&&(c=0),0>c&&(c=h.options.values.length-1),h.value=h.options.values[c]));h.callback&&setTimeout(function(){this.callback(this.value,m,a,b)}.bind(h),20);this.dirty_canvas=!0;break;case "text":"mousedown"==c.type&&this.prompt("Value",h.value,function(a){this.value= +a}.bind(h),c)}return h}}return null};g.prototype.drawGroups=function(a,b){if(this.graph){var c=this.graph._groups;b.save();b.globalAlpha=0.5;b.font="24px Arial";for(var g=0;gc&&0.01>b.editor_alpha&&(clearInterval(g),1>c&&(b.live_mode=!0));1"+q+""+a+"",value:q});if(h.length)return new k.ContextMenu(h,{event:c,callback:l,parentMenu:m,allow_html:!0,node:e},b),!1}};g.decodeHTML=function(a){var b= +document.createElement("div");b.innerText=a;return b.innerHTML};g.onResizeNode=function(a,b,c,g,e){e&&(e.size=e.computeSize(),e.setDirtyCanvas(!0,!0))};g.onShowTitleEditor=function(a,b,c,m,e){function l(){e.title=h.value;d.parentNode.removeChild(d);e.setDirtyCanvas(!0,!0)}var d=document.createElement("div");d.className="graphdialog";d.innerHTML="Title";var h=d.querySelector("input");h&&(h.value=e.title,h.addEventListener("keydown", +function(a){13==a.keyCode&&(l(),a.preventDefault(),a.stopPropagation())}));a=g.active_canvas.canvas;b=a.getBoundingClientRect();m=c=-20;b&&(c-=b.left,m-=b.top);event?(d.style.left=event.pageX+c+"px",d.style.top=event.pageY+m+"px"):(d.style.left=0.5*a.width+c+"px",d.style.top=0.5*a.height+m+"px");d.querySelector("button").addEventListener("click",l);a.parentNode.appendChild(d)};g.prototype.prompt=function(a,b,c,d){var e=this;a=a||"";var l=document.createElement("div");l.className="graphdialog rounded"; +l.innerHTML=" ";l.close=function(){e.prompt_box=null;l.parentNode.removeChild(l)};l.addEventListener("mouseleave",function(a){l.close()});e.prompt_box&&e.prompt_box.close();e.prompt_box=l;l.querySelector(".name").innerText=a;l.querySelector(".value").value=b;var m=l.querySelector("input");m.addEventListener("keydown",function(a){if(27==a.keyCode)l.close();else if(13==a.keyCode)c&&c(this.value), +l.close();else return;a.preventDefault();a.stopPropagation()});l.querySelector("button").addEventListener("click",function(a){c&&c(m.value);e.setDirty(!0);l.close()});a=g.active_canvas.canvas;b=a.getBoundingClientRect();var h=-20,k=-20;b&&(h-=b.left,k-=b.top);d?(l.style.left=d.pageX+h+"px",l.style.top=d.pageY+k+"px"):(l.style.left=0.5*a.width+h+"px",l.style.top=0.5*a.height+k+"px");a.parentNode.appendChild(l);setTimeout(function(){m.focus()},10);return l};g.prototype.showSearchBox=function(a){function b(b){if(b)if(e.onSearchBoxSelection)e.onSearchBoxSelection(b, +a,s);else if(b=k.createNode(b))b.pos=s.convertEventToCanvas(a),s.graph.add(b);l.close()}function c(a){var b=p;p&&p.classList.remove("selected");p?(p=a?p.nextSibling:p.previousSibling)||(p=b):p=a?m.childNodes[0]:m.childNodes[m.childNodes.length];p&&(p.classList.add("selected"),p.scrollIntoView())}function d(){q=null;var a=r.value;h=null;m.innerHTML="";if(a)if(e.onSearchBox)e.onSearchBox(f,a,s);else for(var c in k.registered_node_types)if(-1!=c.indexOf(a)){var f=document.createElement("div");h||(h= +c);f.innerText=c;f.className="help-item";f.addEventListener("click",function(a){b(this.innerText)});m.appendChild(f)}}var e=this,l=document.createElement("div");l.className="graphdialog rounded";l.innerHTML="Search
";l.close=function(){e.search_box=null;l.parentNode.removeChild(l)};l.addEventListener("mouseleave",function(a){l.close()});e.search_box&&e.search_box.close();e.search_box=l;var m=l.querySelector(".helper"), +h=null,q=null,p=null,r=l.querySelector("input");r&&r.addEventListener("keydown",function(a){if(38==a.keyCode)c(!1);else if(40==a.keyCode)c(!0);else if(27==a.keyCode)l.close();else if(13==a.keyCode)p?b(p.innerHTML):h?b(h):l.close();else{q&&clearInterval(q);q=setTimeout(d,10);return}a.preventDefault();a.stopPropagation()});var s=g.active_canvas,u=s.canvas,t=u.getBoundingClientRect(),z=-20,E=-20;t&&(z-=t.left,E-=t.top);a?(l.style.left=a.pageX+z+"px",l.style.top=a.pageY+E+"px"):(l.style.left=0.5*u.width+ +z+"px",l.style.top=0.5*u.height+E+"px");u.parentNode.appendChild(l);setTimeout(function(){r.focus()},10);return l};g.prototype.showEditPropertyValue=function(a,b,c){function g(){e(p.value)}function e(c){"number"==typeof a.properties[b]&&(c=Number(c));"array"==l&&(c=c.split(",").map(Number));a.properties[b]=c;a._graph&&a._graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,c);q.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var l="string";null!==a.properties[b]&& +(l=typeof a.properties[b]);"object"==l&&a.properties[b].length&&(l="array");var m=null;a.getPropertyInfo&&(m=a.getPropertyInfo(b));if(a.properties_info)for(var d=0;d";else if("enum"==l&&m.values){h=""}else if("boolean"==l)h="";else{console.warn("unknown type: "+l);return}var q=this.createDialog(""+b+""+h+"",c);if("enum"==l&&m.values){var p=q.querySelector("select");p.addEventListener("change",function(a){e(a.target.value)})}else if("boolean"== +l)(p=q.querySelector("input"))&&p.addEventListener("click",function(a){e(!!p.checked)});else if(p=q.querySelector("input"))p.value=void 0!==a.properties[b]?a.properties[b]:"",p.addEventListener("keydown",function(a){13==a.keyCode&&(g(),a.preventDefault(),a.stopPropagation())});q.querySelector("button").addEventListener("click",g)}};g.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;var g=this.canvas.getBoundingClientRect(),e= +-20,l=-20;g&&(e-=g.left,l-=g.top);b.position?(e+=b.position[0],l+=b.position[1]):b.event?(e+=b.event.pageX,l+=b.event.pageY):(e+=0.5*this.canvas.width,l+=0.5*this.canvas.height);c.style.left=e+"px";c.style.top=l+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};g.onMenuNodeCollapse=function(a,b,c,g,e){e.collapse()};g.onMenuNodePin=function(a,b,c,g,e){e.pin()};g.onMenuNodeMode=function(a,b,c,g,e){new k.ContextMenu(["Always", +"On Event","On Trigger","Never"],{event:c,callback:function(a){if(e)switch(a){case "On Event":e.mode=k.ON_EVENT;break;case "On Trigger":e.mode=k.ON_TRIGGER;break;case "Never":e.mode=k.NEVER;break;default:e.mode=k.ALWAYS}},parentMenu:g,node:e});return!1};g.onMenuNodeColors=function(a,b,c,m,e){if(!e)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var l in g.node_colors)a=g.node_colors[l],a={value:l,content:""+l+""},b.push(a);new k.ContextMenu(b,{event:c,callback:function(a){e&&((a=a.value?g.node_colors[a.value]:null)?e.constructor===k.LGraphGroup?e.color=a.groupcolor:(e.color=a.color,e.bgcolor=a.bgcolor):(delete e.color,delete e.bgcolor),e.setDirtyCanvas(!0,!0))},parentMenu:m,node:e});return!1};g.onMenuNodeShapes=function(a,b,c,g,e){if(!e)throw"no node passed";new k.ContextMenu(k.VALID_SHAPES,{event:c,callback:function(a){e&&(e.shape=a,e.setDirtyCanvas(!0))}, +parentMenu:g,node:e});return!1};g.onMenuNodeRemove=function(a,b,c,g,e){if(!e)throw"no node passed";!1!==e.removable&&(e.graph.remove(e),e.setDirtyCanvas(!0,!0))};g.onMenuNodeClone=function(a,b,c,g,e){!1!=e.clonable&&(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.add(a),e.setDirtyCanvas(!0,!0))};g.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"},brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223", +bgcolor:"#335",groupcolor:"#88A"},pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"},purple:{color:"#323",bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",groupcolor:"#444"}};g.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:g.onMenuAdd},{content:"Add Group", +callback:g.onGroupAdd}],this._graph_stack&&0Name",e),m=d.querySelector("input"); +d.querySelector("button").addEventListener("click",function(b){if(m.value){if(b=g.input?a.getInputInfo(g.slot):a.getOutputInfo(g.slot))b.label=m.value;c.setDirty(!0)}d.close()})}},extra:a},d=null;a&&(d=a.getSlotInPosition(b.canvasX,b.canvasY),g.active_node=a);d?(e=[],e.push(d.locked?"Cannot remove":{content:"Remove Slot",slot:d}),e.push({content:"Rename Slot",slot:d}),l.title=(d.input?d.input.type:d.output.type)||"*",d.input&&d.input.type==k.ACTION&&(l.title="Action"),d.output&&d.output.type==k.EVENT&& +(l.title="Event")):a?e=this.getNodeMenuOptions(a):(e=this.getCanvasMenuOptions(),(d=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&e.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:d,options:this.getGroupMenuOptions(d)}}));e&&new k.ContextMenu(e,l,m)};this.CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,g,e,l){void 0===e&&(e=5);void 0===l&&(l=e);this.moveTo(a+e,b);this.lineTo(a+c-e,b);this.quadraticCurveTo(a+c,b,a+c,b+e);this.lineTo(a+ +c,b+g-l);this.quadraticCurveTo(a+c,b+g,a+c-l,b+g);this.lineTo(a+l,b+g);this.quadraticCurveTo(a,b+g,a,b+g-l);this.lineTo(a,b+e);this.quadraticCurveTo(a,b,a+e,b)});k.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};k.distance=r;k.colorToString=function(a){return"rgba("+Math.round(255*a[0]).toFixed()+","+Math.round(255*a[1]).toFixed()+","+Math.round(255*a[2]).toFixed()+","+(4==a.length?a[3].toFixed(2):"1.0")+")"};k.isInsideRectangle=p;k.growBounding=function(a,b,c){ba[2]&&(a[2]=b);ca[3]&&(a[3]=c)};k.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};k.overlapBounding=s;k.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,g,e,l=0;6>l;l+=2)g="0123456789ABCDEF".indexOf(a.charAt(l)),e="0123456789ABCDEF".indexOf(a.charAt(l+1)),b[c]=16*g+e,c++;return b};k.num2hex=function(a){for(var b="#",c,g,e=0;3>e;e++)c=a[e]/16,g=a[e]%16,b+="0123456789ABCDEF".charAt(c)+ +"0123456789ABCDEF".charAt(g);return b};u.prototype.addItem=function(a,b,c){function g(a){var b=this.value;b&&b.has_submenu&&e.call(this,a)}function e(a){var b=this.value,e=!0;l.current_submenu&&l.current_submenu.close(a);if(c.callback){var g=c.callback.call(this,b,c,a,l,c.node);!0===g&&(e=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&!0!==b.disabled&&(g=b.callback.call(this,b,c,a,l,c.extra),!0===g&&(e=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new l.constructor(b.submenu.options, +{callback:b.submenu.callback,event:a,parentMenu:l,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});e=!1}e&&!l.lock&&l.close()}var l=this;c=c||{};var d=document.createElement("div");d.className="litemenu-entry submenu";var m=!1;if(null===b)d.classList.add("separator");else{d.innerHTML=b&&b.title?b.title:a;if(d.value=b)b.disabled&&(m=!0,d.classList.add("disabled")),(b.submenu||b.has_submenu)&&d.classList.add("has_submenu");"function"== +typeof b?(d.dataset.value=a,d.onclick_callback=b):d.dataset.value=b;b.className&&(d.className+=" "+b.className)}this.root.appendChild(d);m||d.addEventListener("click",e);c.autoopen&&d.addEventListener("mouseenter",g);return d};u.prototype.close=function(a,b){this.root.parentNode&&this.root.parentNode.removeChild(this.root);this.parentMenu&&!b&&(this.parentMenu.lock=!1,this.parentMenu.current_submenu=null,void 0===a?this.parentMenu.close():a&&!u.isCursorOverElement(a,this.parentMenu.root)&&u.trigger(this.parentMenu.root, +"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0)};u.trigger=function(a,b,c,g){var e=document.createEvent("CustomEvent");e.initCustomEvent(b,!0,!0,c);e.srcElement=g;a.dispatchEvent?a.dispatchEvent(e):a.__events&&a.__events.dispatchEvent(e);return e};u.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};u.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event}; +u.isCursorOverElement=function(a,b){var c=a.pageX,g=a.pageY,e=b.getBoundingClientRect();return e?g>e.top&&ge.left&&c a?b:c","string",{values:e.values});this.size=[60,40]}function l(){this.addInput("inc","number");this.addOutput("total","number");this.addProperty("increment",1);this.addProperty("value",0)}function n(){this.addInput("v","number");this.addOutput("sin","number");this.addProperty("amplitude",1);this.addProperty("offset",0);this.bgImageUrl="nodes/imgs/icon-sin.png"} function C(){this.addInput("vec2","vec2");this.addOutput("x","number");this.addOutput("y","number")}function y(){this.addInputs([["x","number"],["y","number"]]);this.addOutput("vec2","vec2");this.properties={x:0,y:0};this._data=new Float32Array(2)}function x(){this.addInput("vec3","vec3");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z","number")}function A(){this.addInputs([["x","number"],["y","number"],["z","number"]]);this.addOutput("vec3","vec3");this.properties={x:0, y:0,z:0};this._data=new Float32Array(3)}function D(){this.addInput("vec4","vec4");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z","number");this.addOutput("w","number")}function B(){this.addInputs([["x","number"],["y","number"],["z","number"],["w","number"]]);this.addOutput("vec4","vec4");this.properties={x:0,y:0,z:0,w:0};this._data=new Float32Array(4)}var v=t.LiteGraph;h.title="Converter";h.desc="type A to type B";h.prototype.onExecute=function(){var a=this.getInputData(0); -if(null!=a&&this.outputs)for(var b=0;bb&&(this._current=0);for(var c=a=0;cb&&(b=1);this.properties.samples=Math.round(b);var c=this._values;this._values=new Float32Array(this.properties.samples);c.length<=this._values.length?this._values.set(c):this._values.set(c.subarray(0,this._values.length))};v.registerNodeType("math/average",a);b.title="TendTo";b.desc="moves the output value always closer to the input"; b.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b=this.properties.factor;this._value=null==this._value?a:this._value*(1-b)+a*b;this.setOutputData(0,this._value)};v.registerNodeType("math/tendTo",b);f.values="+-*/%^".split("");f.title="Operation";f.desc="Easy math operators";f["@OP"]={type:"enum",title:"operation",values:f.values};f.prototype.getTitle=function(){return"A "+this.properties.OP+" B"};f.prototype.setValue=function(a){"string"==typeof a&&(a=parseFloat(a)); this.properties.value=a};f.prototype.onExecute=function(){var a=this.getInputData(0),b=this.getInputData(1);null!=a?this.properties.A=a:a=this.properties.A;null!=b?this.properties.B=b:b=this.properties.B;var c=0;switch(this.properties.OP){case "+":c=a+b;break;case "-":c=a-b;break;case "x":case "X":case "*":c=a*b;break;case "/":c=a/b;break;case "%":c=a%b;break;case "^":c=Math.pow(a,b);break;default:console.warn("Unknown operation: "+this.properties.OP)}this.setOutputData(0,c)};f.prototype.onDrawBackground= -function(a){this.flags.collapsed||(a.font="40px Arial",a.fillStyle="#CCC",a.textAlign="center",a.fillText(this.properties.OP,0.5*this.size[0],0.35*this.size[1]+v.NODE_TITLE_HEIGHT),a.textAlign="left")};v.registerNodeType("math/operation",f);w.title="Compare";w.desc="compares between two values";w.prototype.onExecute=function(){var a=this.getInputData(0),b=this.getInputData(1);void 0!==a?this.properties.A=a:a=this.properties.A;void 0!==b?this.properties.B=b:b=this.properties.B;for(var c=0,e=this.outputs.length;c< -e;++c){var f=this.outputs[c];if(f.links&&f.links.length){switch(f.name){case "A==B":value=a==b;break;case "A!=B":value=a!=b;break;case "A>B":value=a>b;break;case "A=B":value=a>=b}this.setOutputData(c,value)}}};w.prototype.onGetOutputs=function(){return[["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};v.registerNodeType("math/compare",w);e.values="> < == != <= >=".split(" ");e["@OP"]= +function(a){this.flags.collapsed||(a.font="40px Arial",a.fillStyle="#CCC",a.textAlign="center",a.fillText(this.properties.OP,0.5*this.size[0],0.35*this.size[1]+v.NODE_TITLE_HEIGHT),a.textAlign="left")};v.registerNodeType("math/operation",f);w.title="Compare";w.desc="compares between two values";w.prototype.onExecute=function(){var a=this.getInputData(0),b=this.getInputData(1);void 0!==a?this.properties.A=a:a=this.properties.A;void 0!==b?this.properties.B=b:b=this.properties.B;for(var c=0,d=this.outputs.length;c< +d;++c){var e=this.outputs[c];if(e.links&&e.links.length){switch(e.name){case "A==B":value=a==b;break;case "A!=B":value=a!=b;break;case "A>B":value=a>b;break;case "A=B":value=a>=b}this.setOutputData(c,value)}}};w.prototype.onGetOutputs=function(){return[["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};v.registerNodeType("math/compare",w);e.values="> < == != <= >=".split(" ");e["@OP"]= {type:"enum",title:"operation",values:e.values};e.title="Condition";e.desc="evaluates condition between A and B";e.prototype.onExecute=function(){var a=this.getInputData(0);void 0===a?a=this.properties.A:this.properties.A=a;var b=this.getInputData(1);void 0===b?b=this.properties.B:this.properties.B=b;var c=!0;switch(this.properties.OP){case ">":c=a>b;break;case "<":c=a=":c=a>=b}this.setOutputData(0,c)};v.registerNodeType("math/condition", e);l.title="Accumulate";l.desc="Increments a value every time";l.prototype.onExecute=function(){null===this.properties.value&&(this.properties.value=0);var a=this.getInputData(0);this.properties.value=null!==a?this.properties.value+a:this.properties.value+this.properties.increment;this.setOutputData(0,this.properties.value)};v.registerNodeType("math/accumulate",l);n.title="Trigonometry";n.desc="Sin Cos Tan";n.filter="shader";n.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a= -0);var b=this.properties.amplitude,c=this.findInputSlot("amplitude");-1!=c&&(b=this.getInputData(c));var e=this.properties.offset,c=this.findInputSlot("offset");-1!=c&&(e=this.getInputData(c));for(var c=0,f=this.outputs.length;cXY";C.desc="vector 2 to components";C.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]))};v.registerNodeType("math3d/vec2-to-xyz",C);y.title="XY->Vec2";y.desc="components to vector2";y.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this._data;c[0]=a;c[1]=b;this.setOutputData(0,c)};v.registerNodeType("math3d/xy-to-vec2", y);x.title="Vec3->XYZ";x.desc="vector 3 to components";x.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]),this.setOutputData(2,a[2]))};v.registerNodeType("math3d/vec3-to-xyz",x);A.title="XYZ->Vec3";A.desc="components to vector3";A.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this.getInputData(2);null==c&&(c=this.properties.z); -var e=this._data;e[0]=a;e[1]=b;e[2]=c;this.setOutputData(0,e)};v.registerNodeType("math3d/xyz-to-vec3",A);D.title="Vec4->XYZW";D.desc="vector 4 to components";D.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]),this.setOutputData(2,a[2]),this.setOutputData(3,a[3]))};v.registerNodeType("math3d/vec4-to-xyzw",D);B.title="XYZW->Vec4";B.desc="components to vector4";B.prototype.onExecute=function(){var a=this.getInputData(0);null== -a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this.getInputData(2);null==c&&(c=this.properties.z);var e=this.getInputData(3);null==e&&(e=this.properties.w);var f=this._data;f[0]=a;f[1]=b;f[2]=c;f[3]=e;this.setOutputData(0,f)};v.registerNodeType("math3d/xyzw-to-vec4",B);t.glMatrix&&(t=function(){this.addOutput("quat","quat");this.properties={x:0,y:0,z:0,w:1};this._value=quat.create()},t.title="Quaternion",t.desc="quaternion",t.prototype.onExecute=function(){this._value[0]= +var d=this._data;d[0]=a;d[1]=b;d[2]=c;this.setOutputData(0,d)};v.registerNodeType("math3d/xyz-to-vec3",A);D.title="Vec4->XYZW";D.desc="vector 4 to components";D.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]),this.setOutputData(2,a[2]),this.setOutputData(3,a[3]))};v.registerNodeType("math3d/vec4-to-xyzw",D);B.title="XYZW->Vec4";B.desc="components to vector4";B.prototype.onExecute=function(){var a=this.getInputData(0);null== +a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this.getInputData(2);null==c&&(c=this.properties.z);var d=this.getInputData(3);null==d&&(d=this.properties.w);var e=this._data;e[0]=a;e[1]=b;e[2]=c;e[3]=d;this.setOutputData(0,e)};v.registerNodeType("math3d/xyzw-to-vec4",B);t.glMatrix&&(t=function(){this.addOutput("quat","quat");this.properties={x:0,y:0,z:0,w:1};this._value=quat.create()},t.title="Quaternion",t.desc="quaternion",t.prototype.onExecute=function(){this._value[0]= this.properties.x;this._value[1]=this.properties.y;this._value[2]=this.properties.z;this._value[3]=this.properties.w;this.setOutputData(0,this._value)},v.registerNodeType("math3d/quaternion",t),t=function(){this.addInputs([["degrees","number"],["axis","vec3"]]);this.addOutput("quat","quat");this.properties={angle:90,axis:vec3.fromValues(0,1,0)};this._value=quat.create()},t.title="Rotation",t.desc="quaternion rotation",t.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.angle); var b=this.getInputData(1);null==b&&(b=this.properties.axis);a=quat.setAxisAngle(this._value,b,0.0174532925*a);this.setOutputData(0,a)},v.registerNodeType("math3d/rotation",t),t=function(){this.addInputs([["vec3","vec3"],["quat","quat"]]);this.addOutput("result","vec3");this.properties={vec:[0,0,1]}},t.title="Rot. Vec3",t.desc="rotate a point",t.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.vec);var b=this.getInputData(1);null==b?this.setOutputData(a):this.setOutputData(0, vec3.transformQuat(vec3.create(),a,b))},v.registerNodeType("math3d/rotate_vec3",t),t=function(){this.addInputs([["A","quat"],["B","quat"]]);this.addOutput("A*B","quat");this._value=quat.create()},t.title="Mult. Quat",t.desc="rotate quaternion",t.prototype.onExecute=function(){var a=this.getInputData(0);if(null!=a){var b=this.getInputData(1);null!=b&&(a=quat.multiply(this._value,a,b),this.setOutputData(0,a))}},v.registerNodeType("math3d/mult-quat",t),t=function(){this.addInputs([["A","quat"],["B", diff --git a/src/litegraph.js b/src/litegraph.js index 3ff710ea5..2dc1636b7 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -41,6 +41,7 @@ var LiteGraph = global.LiteGraph = { NODE_DEFAULT_BGCOLOR: "#444", NODE_DEFAULT_BOXCOLOR: "#666", NODE_DEFAULT_SHAPE: "box", + DEFAULT_SHADOW_COLOR: "rgba(0,0,0,0.5)", LINK_COLOR: "#AAD", EVENT_LINK_COLOR: "#F85", @@ -5248,16 +5249,12 @@ LGraphCanvas.prototype.drawNode = function(node, ctx ) return; } - //custom draw collapsed method - if(node.flags.collapsed && node.onDrawCollaped && node.onDrawCollapsed(ctx, this) == true) - return; - var editor_alpha = this.editor_alpha; ctx.globalAlpha = editor_alpha; if(this.render_shadows) { - ctx.shadowColor = "rgba(0,0,0,0.5)"; + ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR; ctx.shadowOffsetX = 2 * this.scale; ctx.shadowOffsetY = 2 * this.scale; ctx.shadowBlur = 3 * this.scale; @@ -5265,6 +5262,10 @@ LGraphCanvas.prototype.drawNode = function(node, ctx ) else ctx.shadowColor = "transparent"; + //custom draw collapsed method (draw after shadows because they are affected) + if(node.flags.collapsed && node.onDrawCollaped && node.onDrawCollapsed(ctx, this) == true) + return; + //clip if required (mask) var shape = node._shape || LiteGraph.BOX_SHAPE; var size = temp_vec2; @@ -5562,6 +5563,9 @@ LGraphCanvas.prototype.drawNodeShape = function( node, ctx, size, fgcolor, bgcol //title bar if(title_mode != LiteGraph.TRANSPARENT_TITLE) //!node.flags.collapsed) { + if(node.flags.collapsed) + ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR; + //* gradient test if(this.use_gradients) { @@ -5591,15 +5595,7 @@ LGraphCanvas.prototype.drawNodeShape = function( node, ctx, size, fgcolor, bgcol ctx.roundRect(0,-title_height,size[0]+1, title_height, this.round_radius, node.flags.collapsed ? this.round_radius : 0); ctx.fill(); } - - /* - else if (shape == LiteGraph.CIRCLE_SHAPE) - { - ctx.beginPath(); - ctx.arc(title_height *0.5, title_height * -0.5, (title_height - 6) *0.5,0,Math.PI*2); - ctx.fill(); - } - */ + ctx.shadowColor = "transparent"; } //title box @@ -6024,7 +6020,8 @@ LGraphCanvas.prototype.drawNodeWidgets = function( node, posY, ctx, active_widge ctx.fill(); ctx.stroke(); ctx.fillStyle = "#999"; - ctx.fillText( w.title || "Value", 20, y + H*0.7 ); + if(w.name != null) + ctx.fillText( w.name, 20, y + H*0.7 ); ctx.fillStyle = "#DDD"; ctx.textAlign = "right"; ctx.fillText( w.value, width - 20, y + H*0.7 );