From 33d527541a5e450679fbd1542af5a1d32fcda978 Mon Sep 17 00:00:00 2001 From: tamat Date: Wed, 24 Oct 2018 15:32:40 +0200 Subject: [PATCH] moved default color to LiteGraph.LINK_COLOR --- build/litegraph.js | 18 +++++++++++------- build/litegraph.min.js | 42 +++++++++++++++++++++--------------------- src/litegraph.js | 18 +++++++++++------- 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/build/litegraph.js b/build/litegraph.js index 6c8c2fcd7..0ad6cf0c1 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -26,6 +26,8 @@ var LiteGraph = global.LiteGraph = { + CANVAS_GRID_SIZE: 10, + NODE_TITLE_HEIGHT: 20, NODE_SLOT_HEIGHT: 15, NODE_WIDGET_HEIGHT: 20, @@ -33,7 +35,6 @@ var LiteGraph = global.LiteGraph = { NODE_MIN_WIDTH: 50, NODE_COLLAPSED_RADIUS: 10, NODE_COLLAPSED_WIDTH: 80, - CANVAS_GRID_SIZE: 10, NODE_TITLE_COLOR: "#999", NODE_TEXT_SIZE: 14, NODE_TEXT_COLOR: "#AAA", @@ -42,10 +43,12 @@ var LiteGraph = global.LiteGraph = { NODE_DEFAULT_BGCOLOR: "#444", NODE_DEFAULT_BOXCOLOR: "#888", NODE_DEFAULT_SHAPE: "box", + + LINK_COLOR: "#AAD", + EVENT_LINK_COLOR: "#F85", + MAX_NUMBER_OF_NODES: 1000, //avoid infinite loops DEFAULT_POSITION: [100,100],//default node position - node_images_path: "", - VALID_SHAPES: ["default","box","round","card"], //,"circle" //shapes are used for nodes but also for slots @@ -73,6 +76,7 @@ var LiteGraph = global.LiteGraph = { AUTOHIDE_TITLE: 3, proxy: null, //used to redirect calls + node_images_path: "", debug: false, throw_errors: true, @@ -3240,7 +3244,7 @@ function LGraphCanvas( canvas, graph, options ) this.title_text_font = "bold "+LiteGraph.NODE_TEXT_SIZE+"px Arial"; this.inner_text_font = "normal "+LiteGraph.NODE_SUBTEXT_SIZE+"px Arial"; this.node_title_color = LiteGraph.NODE_TITLE_COLOR; - this.default_link_color = "#AAC"; + this.default_link_color = LiteGraph.LINK_COLOR; this.default_connection_color = { input_off: "#AAB", input_on: "#7F7", @@ -4994,9 +4998,9 @@ LGraphCanvas.prototype.drawFrontCanvas = function() var link_color = null; switch( this.connecting_output.type ) { - case LiteGraph.EVENT: link_color = "#F85"; break; + case LiteGraph.EVENT: link_color = LiteGraph.EVENT_LINK_COLOR; break; default: - link_color = "#AFA"; + link_color = this.default_link_color; } //the connection being dragged by the mouse this.renderLink( ctx, this.connecting_pos, [this.canvas_mouse[0],this.canvas_mouse[1]], null, false, null, link_color ); @@ -5716,7 +5720,7 @@ LGraphCanvas.prototype.renderLink = function( ctx, a, b, link, skip_border, flow //choose color if( !color && link ) color = LGraphCanvas.link_type_colors[ link.type ]; - if(!color) + if( !color ) color = this.default_link_color; if( link != null && this.highlighted_links[ link.id ] ) diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 1f975a572..281f450bc 100755 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -1,14 +1,14 @@ (function(s){function h(a){l.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function e(a){this._ctor(a)}function n(a){this._ctor(a)}function d(a,b,g){g=g||{};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.max_zoom=10;this.min_zoom=0.1;this.zoom_modify_alpha=!0;this.title_text_font="bold "+l.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+l.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=l.NODE_TITLE_COLOR;this.default_link_color="#AAC";this.default_connection_color={input_off:"#AAB",input_on:"#7F7",output_off:"#AAB",output_on:"#7F7"};this.highquality_render=!0;this.use_gradients=!1;this.editor_alpha=1;this.pause_rendering=!1; -this.render_only_selected=this.clear_background=this.render_shadows=!0;this.live_mode=!1;this.allow_searchbox=this.allow_interaction=this.allow_dragnodes=this.allow_dragcanvas=this.show_info=!0;this.drag_mode=!1;this.filter=this.dragging_rectangle=null;this.always_render_background=!1;this.render_canvas_border=!0;this.render_connections_shadows=!1;this.render_connection_arrows=this.render_curved_connections=this.render_connections_border=!0;this.canvas_mouse=[0,0];this.onSearchBoxSelection=this.onSearchBox= +a&&a.constructor===String&&(a=document.querySelector(a));this.max_zoom=10;this.min_zoom=0.1;this.zoom_modify_alpha=!0;this.title_text_font="bold "+l.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+l.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=l.NODE_TITLE_COLOR;this.default_link_color=l.LINK_COLOR;this.default_connection_color={input_off:"#AAB",input_on:"#7F7",output_off:"#AAB",output_on:"#7F7"};this.highquality_render=!0;this.use_gradients=!1;this.editor_alpha=1;this.pause_rendering= +!1;this.render_only_selected=this.clear_background=this.render_shadows=!0;this.live_mode=!1;this.allow_searchbox=this.allow_interaction=this.allow_dragnodes=this.allow_dragcanvas=this.show_info=!0;this.drag_mode=!1;this.filter=this.dragging_rectangle=null;this.always_render_background=!1;this.render_canvas_border=!0;this.render_connections_shadows=!1;this.render_connection_arrows=this.render_curved_connections=this.render_connections_border=!0;this.canvas_mouse=[0,0];this.onSearchBoxSelection=this.onSearchBox= null;this.connections_width=3;this.round_radius=8;this.node_widget=this.current_node=null;this.last_mouse_position=[0,0];b&&b.attachCanvas(this);this.setCanvas(a);this.clear();g.skip_render||this.startRendering();this.autoresize=g.autoresize}function r(a,b){return Math.sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]))}function q(a,b,g,c,f,k){return ga&&cb?!0:!1}function t(a,b){var g=a[0]+a[2],c=a[1]+a[3],f=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>f||gd.width-l.width-10&&(k=d.width-l.width-10);p>d.height-l.height-10&&(p=d.height-l.height-10)}f.style.left=k+"px";f.style.top=p+"px"}var l=s.LiteGraph={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,CANVAS_GRID_SIZE:10,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:"#888",NODE_DEFAULT_SHAPE:"box",MAX_NUMBER_OF_NODES:1E3,DEFAULT_POSITION:[100,100],node_images_path:"",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,NORMAL_TITLE:0, -NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,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;l.debug&&console.log("Node registered: "+a);a.split("/");var g=b.name,c=a.lastIndexOf("/");b.category=a.substr(0,c);b.title||(b.title=g);if(b.prototype)for(var f in e.prototype)b.prototype[f]||(b.prototype[f]= -e.prototype[f]);Object.defineProperty(b.prototype,"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=l.BOX_SHAPE;break;case "round":this._shape=l.ROUND_SHAPE;break;case "circle":this._shape=l.CIRCLE_SHAPE;break;case "card":this._shape=l.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[g]=b);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+ +k=b.left||0;p=b.top||0;if(b.event){k=b.event.pageX-10;p=b.event.pageY-10;b.title&&(p-=20);b.parentMenu&&(k=b.parentMenu.root.getBoundingClientRect(),k=k.left+k.width);var d=document.body.getBoundingClientRect(),l=f.getBoundingClientRect();k>d.width-l.width-10&&(k=d.width-l.width-10);p>d.height-l.height-10&&(p=d.height-l.height-10)}f.style.left=k+"px";f.style.top=p+"px"}var l=s.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:"#888",NODE_DEFAULT_SHAPE:"box",LINK_COLOR:"#AAD",EVENT_LINK_COLOR:"#F85",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,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;l.debug&&console.log("Node registered: "+a);a.split("/");var g=b.name,c=a.lastIndexOf("/");b.category=a.substr(0,c);b.title||(b.title=g);if(b.prototype)for(var f in e.prototype)b.prototype[f]|| +(b.prototype[f]=e.prototype[f]);Object.defineProperty(b.prototype,"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=l.BOX_SHAPE;break;case "round":this._shape=l.ROUND_SHAPE;break;case "circle":this._shape=l.CIRCLE_SHAPE;break;case "card":this._shape=l.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[g]=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(f in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[f].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,g,c){for(var f=Array(b.length),k="",p=l.getParameterNames(b),d=0;dc-this.graph._last_trigger_time)&&this.drawBackCanvas();(this.dirty_canvas||a)&&this.drawFrontCanvas();this.fps=this.render_time?1/this.render_time:0;this.frame+=1}};d.prototype.drawFrontCanvas=function(){this.dirty_canvas=!1;this.ctx||(this.ctx=this.bgcanvas.getContext("2d"));var a=this.ctx;if(a){a.start2D&& a.start2D();var b=this.canvas;a.restore();a.setTransform(1,0,0,1,0,0);this.dirty_area&&(a.save(),a.beginPath(),a.rect(this.dirty_area[0],this.dirty_area[1],this.dirty_area[2],this.dirty_area[3]),a.clip());this.clear_background&&a.clearRect(0,0,b.width,b.height);this.bgcanvas==this.canvas?this.drawBackCanvas():a.drawImage(this.bgcanvas,0,0);if(this.onRender)this.onRender(b,a);this.show_info&&this.renderInfo(a);if(this.graph){a.save();a.scale(this.scale,this.scale);a.translate(this.offset[0],this.offset[1]); -for(var b=this.computeVisibleNodes(null,this.visible_nodes),c=0;cthis.scale?(b.beginPath(),b.rect(0,p,n,q),b.fill()):e==l.ROUND_SHAPE||e==l.CARD_SHAPE?(b.beginPath(),b.roundRect(0,p,n,q,this.round_radius,e==l.CARD_SHAPE?0:this.round_radius),b.fill()):e==l.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(y||h==l.TRANSPARENT_TITLE){if(h!=l.TRANSPARENT_TITLE){if(this.use_gradients){var r=d.gradients[m];r||(r=d.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(e==l.BOX_SHAPE||0.5>this.scale)b.rect(0,-f,c[0]+1,f),b.fill();else if(e==l.ROUND_SHAPE||e==l.CARD_SHAPE)b.roundRect(0,-f,c[0]+1,f,this.round_radius,a.flags.collapsed?this.round_radius:0),b.fill()}b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR;b.beginPath();e==l.ROUND_SHAPE||e==l.CIRCLE_SHAPE||e==l.CARD_SHAPE?b.arc(0.5*f,-0.5*f,0.5*(f-8),0,2*Math.PI):b.rect(4,-f+4,f-8,f-8);b.fill();b.globalAlpha=r;0.5