add arrow shape

This commit is contained in:
inventivetalent
2018-10-19 17:15:53 +02:00
parent 6196cd7981
commit 88769e7f72

View File

@@ -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)