From 88769e7f72eca6670454c7357f29241d99bcb679 Mon Sep 17 00:00:00 2001 From: inventivetalent Date: Fri, 19 Oct 2018 17:15:53 +0200 Subject: [PATCH] add arrow shape --- src/litegraph.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/litegraph.js b/src/litegraph.js index 1f4af8aa3..6f7d041cc 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -50,6 +50,7 @@ var LiteGraph = global.LiteGraph = { ROUND_SHAPE: 2, CIRCLE_SHAPE: 3, CARD_SHAPE: 4, + ARROW_SHAPE: 5, //enums INPUT: 1, @@ -5241,10 +5242,19 @@ LGraphCanvas.prototype.drawNode = function(node, ctx ) ctx.beginPath(); - if (slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE) - ctx.rect((pos[0] - 6) + 0.5, (pos[1] - 5) + 0.5,14,10); - else - ctx.arc(pos[0],pos[1],4,0,Math.PI*2); + if (slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE) { + ctx.rect((pos[0] - 6) + 0.5, (pos[1] - 5) + 0.5, 14, 10); + } else if (slot.shape === LiteGraph.ARROW_SHAPE) { + ctx.beginPath(); + ctx.moveTo(pos[0] + 8, pos[1] + 0.5); + ctx.lineTo(pos[0] - 4, (pos[1] + 6) + 0.5); + ctx.lineTo(pos[0] - 4, (pos[1] - 6) + 0.5); + ctx.closePath(); + + ctx.fill(); + } else { + ctx.arc(pos[0], pos[1], 4, 0, Math.PI * 2); + } ctx.fill(); @@ -5281,10 +5291,20 @@ LGraphCanvas.prototype.drawNode = function(node, ctx ) ctx.beginPath(); //ctx.rect( node.size[0] - 14,i*14,10,10); - if (slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE) + if (slot.type === LiteGraph.EVENT || slot.shape === LiteGraph.BOX_SHAPE) { ctx.rect((pos[0] - 6) + 0.5,(pos[1] - 5) + 0.5,14,10); - else - ctx.arc( pos[0],pos[1],4,0, Math.PI*2 ); + } else if (slot.shape === LiteGraph.ARROW_SHAPE) { + ctx.beginPath(); + ctx.moveTo(pos[0] + 8, pos[1] + 0.5); + ctx.lineTo(pos[0] - 4, (pos[1] + 6) + 0.5); + ctx.lineTo(pos[0] - 4, (pos[1] - 6) + 0.5); + ctx.closePath(); + + ctx.stroke(); + ctx.fill(); + } else { + ctx.arc(pos[0], pos[1], 4, 0, Math.PI * 2); + } //trigger //if(slot.node_id != null && slot.slot == -1)