graflow: test for all directions
This commit is contained in:
19
bzGraflow.js
19
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)
|
||||
|
||||
Reference in New Issue
Block a user