SandeshPnk
SandeshPnk

Reputation: 13

How can i add bezier curve to Path in konva?

Could you please guide me on how bezier curve can be added to Path. Thanks!

here is my demo - linkhere is my codepen

Upvotes: 0

Views: 306

Answers (1)

lavrton
lavrton

Reputation: 20373

You can generate svg path with bezier curve like this:

function computeQuadraticBezierPathData(p1, p2, p3) {
  const pathData = `M${p1.x},${p1.y} Q${p2.x},${p2.y} ${p3.x},${p3.y}`;
  return pathData;
}

To the Konva.Path do this:

function updateLine() {
  var newpoints = computeQuadraticBezierPathData(circle1.position(), anchor.position(), circle2.position());
  path.setData(newpoints);
}

https://codepen.io/lavrton/pen/BaqoKJm

Upvotes: 2

Related Questions