@ -101,6 +101,47 @@ class BezierEdgeBase extends EdgeBase {
return minDistance ;
}
/ * *
* Draw a bezier curve between two nodes
*
* The method accepts zero , one or two control points .
* Passing zero control points just draws a straight line
*
* @ param { CanvasRenderingContext2D } ctx
* @ param { Object } values | options for shadow drawing
* @ param { Object | undefined } viaNode1 | first control point for curve drawing
* @ param { Object | undefined } viaNode2 | second control point for curve drawing
*
* @ protected
* /
_bezierCurve ( ctx , values , viaNode1 , viaNode2 ) {
var hasNode1 = ( viaNode1 !== undefined && viaNode1 . x !== undefined ) ;
var hasNode2 = ( viaNode2 !== undefined && viaNode2 . x !== undefined ) ;
ctx . beginPath ( ) ;
ctx . moveTo ( this . fromPoint . x , this . fromPoint . y ) ;
if ( hasNode1 && hasNode2 ) {
ctx . bezierCurveTo ( viaNode1 . x , viaNode1 . y , viaNode2 . x , viaNode2 . y , this . toPoint . x , this . toPoint . y ) ;
} else if ( hasNode1 ) {
ctx . quadraticCurveTo ( viaNode1 . x , viaNode1 . y , this . toPoint . x , this . toPoint . y ) ;
} else {
// fallback to normal straight edge
ctx . lineTo ( this . toPoint . x , this . toPoint . y ) ;
}
// draw shadow if enabled
this . enableShadow ( ctx , values ) ;
ctx . stroke ( ) ;
this . disableShadow ( ctx , values ) ;
}
getViaNode ( ) {
return this . _getViaCoordinates ( ) ;
}
}
export default BezierEdgeBase ;
export default BezierEdgeBase ;