Skip to content

Instantly share code, notes, and snippets.

@tj
Last active November 26, 2019 15:43
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tj/fe0ccd4a994d73acea375024fc962af9 to your computer and use it in GitHub Desktop.
Save tj/fe0ccd4a994d73acea375024fc962af9 to your computer and use it in GitHub Desktop.
import React from 'react'
const bgStyles = {
strokeWidth: 3,
strokeLinejoin: 'round',
strokeLinecap: 'round',
fill: 'none',
stroke: '#c3fdff'
}
const fgStyles = {
strokeWidth: 1,
strokeLinejoin: 'round',
strokeLinecap: 'round',
fill: 'none',
stroke: '#6CDADE'
}
function spline(a, b, n = 50) {
return `M${a.x},${a.y} C${a.x + n},${a.y} ${b.x - n},${b.y} ${b.x},${b.y}`
}
export default function Connection({ from, to }) {
return <g>
<path d={spline(from, to)} style={bgStyles} />
<path d={spline(from, to)} style={fgStyles} />
</g>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment