diff --git a/bzGraflow.js b/bzGraflow.js index bcf2b3d..3ceade5 100644 --- a/bzGraflow.js +++ b/bzGraflow.js @@ -499,14 +499,19 @@ class BZgraflow extends Buildoz{ return(`M ${x1} ${y1} C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`) } if(wireType === 'straight') { - console.log('straight') - // Straight segments through the same control points return(`M ${x1} ${y1} L ${c1x} ${c1y} L ${c2x} ${c2y} L ${x2} ${y2}`) } + if(wireType === 'ortho') { + let path = `M ${x1} ${y1} ` + if(['n', 's'].includes(port1.direction)) { + path += `V ${(c1y+c2y)/2} H ${c2x} V ${y2}` + } else { + path += `H ${(c1x+c2x)/2} V ${c2y} H ${x2}` + } + return(path) + } return('') - //return(`M ${x1} ${y1} C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`) } - linkInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal') { const tension = parseInt(this.getBZAttribute('tension')) || 60 const wireType = this.getBZAttribute('wiretype') || 'bezier' @@ -541,7 +546,16 @@ class BZgraflow extends Buildoz{ if(wireType === 'straight') { return(`L ${c1x} ${c1y} L ${c2x} ${c2y} L ${x2} ${y2}`) } - return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`) + if(wireType === 'ortho') { + let path = `M ${x1} ${y1} ` + if(['n', 's'].includes(port1.direction)) { + path += `V ${(c1y+c2y)/2} H ${c2x} V ${y2}` + } else { + path += `H ${(c1x+c2x)/2} V ${c2y} H ${x2}` + } + return(path) + } + return(``) } // Start/end points in SVG coords (works for both bezier and line)