From fc16a1840f74a897b23600b51de24227501c1938 Mon Sep 17 00:00:00 2001 From: STEINNI Date: Mon, 2 Mar 2026 21:27:33 +0000 Subject: [PATCH] graflow: test for all directions --- bzGraflow.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bzGraflow.js b/bzGraflow.js index b87b54f..7431b5a 100644 --- a/bzGraflow.js +++ b/bzGraflow.js @@ -459,20 +459,18 @@ class BZgraflow extends Buildoz{ return({ x: x - r.left, y: y - r.top }) } - emitWireSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop=false){ + buildSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop=false){ if(loop) wireType = 'bezier' // loops only use bezier to look good - if(wireType === 'bezier'){ + if(wireType == 'bezier'){ return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`) } - if(wireType === 'straight'){ + if(wireType == 'straight'){ return(`L ${c1x} ${c1y} L ${c2x} ${c2y} L ${x2} ${y2}`) } - if(wireType === 'ortho'){ - if(startAxis === 'v'){ - return(`V ${(c1y + c2y) / 2} H ${c2x} V ${y2}`) - } - return(`H ${(c1x + c2x) / 2} V ${c2y} H ${x2}`) + if(wireType == 'ortho'){ + if(startAxis == 'v') return(`V ${(c1y + c2y) / 2} H ${c2x} V ${y2}`) + else return(`H ${(c1x + c2x) / 2} V ${c2y} H ${x2}`) } return('') } @@ -513,10 +511,11 @@ class BZgraflow extends Buildoz{ } } const startAxis = ['n', 's'].includes(port1.direction) ? 'v' : 'h' - const seg = this.emitWireSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop) + const seg = this.buildSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, loop) if(!seg) return('') return(`M ${x1} ${y1} ${seg}`) } + linkInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal') { const tension = parseInt(this.getBZAttribute('tension')) || 60 const wireType = this.getBZAttribute('wiretype') || 'bezier' @@ -546,7 +545,7 @@ class BZgraflow extends Buildoz{ c2y = Math.floor(y2 - tension) } const startAxis = (orientation1=='vertical') ? 'v' : 'h' - return(this.emitWireSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, false)) + return(this.buildSegment(x1, y1, c1x, c1y, c2x, c2y, x2, y2, wireType, startAxis, false)) } // Start/end points in SVG coords (works for both bezier and line)