graflow: test for all directions

This commit is contained in:
STEINNI
2026-03-02 21:27:33 +00:00
parent 4b107e772c
commit fc16a1840f

View File

@@ -459,20 +459,18 @@ class BZgraflow extends Buildoz{
return({ x: x - r.left, y: y - r.top }) 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(loop) wireType = 'bezier' // loops only use bezier to look good
if(wireType === 'bezier'){ if(wireType == 'bezier'){
return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`) return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`)
} }
if(wireType === 'straight'){ if(wireType == 'straight'){
return(`L ${c1x} ${c1y} L ${c2x} ${c2y} L ${x2} ${y2}`) return(`L ${c1x} ${c1y} L ${c2x} ${c2y} L ${x2} ${y2}`)
} }
if(wireType === 'ortho'){ if(wireType == 'ortho'){
if(startAxis === 'v'){ if(startAxis == 'v') return(`V ${(c1y + c2y) / 2} H ${c2x} V ${y2}`)
return(`V ${(c1y + c2y) / 2} H ${c2x} V ${y2}`) else return(`H ${(c1x + c2x) / 2} V ${c2y} H ${x2}`)
}
return(`H ${(c1x + c2x) / 2} V ${c2y} H ${x2}`)
} }
return('') return('')
} }
@@ -513,10 +511,11 @@ class BZgraflow extends Buildoz{
} }
} }
const startAxis = ['n', 's'].includes(port1.direction) ? 'v' : 'h' 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('') if(!seg) return('')
return(`M ${x1} ${y1} ${seg}`) return(`M ${x1} ${y1} ${seg}`)
} }
linkInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal') { linkInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal') {
const tension = parseInt(this.getBZAttribute('tension')) || 60 const tension = parseInt(this.getBZAttribute('tension')) || 60
const wireType = this.getBZAttribute('wiretype') || 'bezier' const wireType = this.getBZAttribute('wiretype') || 'bezier'
@@ -546,7 +545,7 @@ class BZgraflow extends Buildoz{
c2y = Math.floor(y2 - tension) c2y = Math.floor(y2 - tension)
} }
const startAxis = (orientation1=='vertical') ? 'v' : 'h' 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) // Start/end points in SVG coords (works for both bezier and line)