graflow: cleanup minTension VS tension
This commit is contained in:
15
bzGraflow.js
15
bzGraflow.js
@@ -251,7 +251,8 @@ testEl.classList.add('eic')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bezierNodes(idNode1, idPort1, idNode2, idPort2, tensionMin=60) {
|
bezierNodes(idNode1, idPort1, idNode2, idPort2, tension=60) {
|
||||||
|
tension = parseInt(tension)
|
||||||
const svgRect = this.wiresContainer.getBoundingClientRect()
|
const svgRect = this.wiresContainer.getBoundingClientRect()
|
||||||
const node1 = this.stagedNodes[idNode1]
|
const node1 = this.stagedNodes[idNode1]
|
||||||
const port1 = node1.ports[idPort1]
|
const port1 = node1.ports[idPort1]
|
||||||
@@ -269,9 +270,6 @@ testEl.classList.add('eic')
|
|||||||
const y2 = Math.floor(bb2.y + (bb2.height/2)) - svgRect.top
|
const y2 = Math.floor(bb2.y + (bb2.height/2)) - svgRect.top
|
||||||
const loop = (idNode1==idNode2) && (idPort1==idPort2)
|
const loop = (idNode1==idNode2) && (idPort1==idPort2)
|
||||||
const dist = Math.abs(x2 - x1) + Math.abs(y2 - y1)
|
const dist = Math.abs(x2 - x1) + Math.abs(y2 - y1)
|
||||||
let tension = dist * 0.4
|
|
||||||
if(tension < tensionMin) tension = parseInt(tensionMin)
|
|
||||||
|
|
||||||
|
|
||||||
let c1x = Math.floor(x1 + (this.dirVect[port1.direction].x * tension))
|
let c1x = Math.floor(x1 + (this.dirVect[port1.direction].x * tension))
|
||||||
let c1y = Math.floor(y1 + (this.dirVect[port1.direction].y * tension))
|
let c1y = Math.floor(y1 + (this.dirVect[port1.direction].y * tension))
|
||||||
@@ -290,16 +288,15 @@ testEl.classList.add('eic')
|
|||||||
return(`M ${x1} ${y1} C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`)
|
return(`M ${x1} ${y1} C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
bezierInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal', tensionMin=60) {
|
bezierInterNodes(idNode1, idPort1, idNode2, idPort2, interNodes, orientation='horizontal', tension=60) {
|
||||||
|
tension = parseInt(tension)
|
||||||
const svgRect = this.wiresContainer.getBoundingClientRect()
|
const svgRect = this.wiresContainer.getBoundingClientRect()
|
||||||
const node1 = this.stagedNodes[idNode1]
|
const node1 = this.stagedNodes[idNode1]
|
||||||
let port1 = node1.ports[idPort1]
|
let port1 = node1.ports[idPort1]
|
||||||
|
|
||||||
const makeCubicBezier = (x1, y1, x2, y2, orientation1, orientation2) => {
|
const makeCubicBezier = (x1, y1, x2, y2, orientation1, orientation2) => {
|
||||||
const dist = Math.abs(x2 - x1) + Math.abs(y2 - y1)
|
const dist = Math.abs(x2 - x1) + Math.abs(y2 - y1)
|
||||||
let tension = dist * 0.4
|
|
||||||
// if(tension < tensionMin)
|
|
||||||
tension = parseInt(tensionMin)
|
|
||||||
let c1x, c1y, c2x, c2y
|
let c1x, c1y, c2x, c2y
|
||||||
if(orientation1=='horizontal'){
|
if(orientation1=='horizontal'){
|
||||||
c1x = Math.floor(x1 + tension)
|
c1x = Math.floor(x1 + tension)
|
||||||
@@ -317,7 +314,7 @@ testEl.classList.add('eic')
|
|||||||
}
|
}
|
||||||
return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`)
|
return(`C ${c1x} ${c1y}, ${c2x} ${c2y}, ${x2} ${y2}`)
|
||||||
}
|
}
|
||||||
const directPath = this.bezierNodes(idNode1, idPort1, idNode2, idPort2, tensionMin)
|
const directPath = this.bezierNodes(idNode1, idPort1, idNode2, idPort2, tension)
|
||||||
const startPath = directPath.substring(0,directPath.indexOf('C'))
|
const startPath = directPath.substring(0,directPath.indexOf('C'))
|
||||||
const endPath = directPath.substring(directPath.lastIndexOf(',')+1).trim()
|
const endPath = directPath.substring(directPath.lastIndexOf(',')+1).trim()
|
||||||
let path = startPath
|
let path = startPath
|
||||||
|
|||||||
Reference in New Issue
Block a user