How to calculate control points for

It’d be useful to know by the documentation of JUCE, how to calculate the control points for the Path::quadraticTo and Path::cubicTo functions.

Or perhaps I can use the parametric versions?

Well, you posted exactly the link to the graphic to solve that question:

Point<float> p0, p1, p2, p3;
Path p;
p.startNewSubPath (p0);
p.cubicTo (p1, p2, p3);

Does that help?

Hi there, I am trying to exactly do this, but throughout 8 points… I am stuck after p3… I cannot add another p to the p.cubicTo, and if I add a new p.cubicTo(p4, p5, p6), etc. the corner of p3 → p4 is not curved.

How can I create a muliti-path line with a cubic curve?

If you have one line with a start point p0, an end point p3, and two control points p1, p2, then to extend that to add a second section (p4, p5, p6, p7) that “flows” with the previous one you need to first set p4 to be the same as p3, then ensure that the line from p2 to p5 passes through p3 and p4:

Thank you for the reply - I understand the theory, but I havent been able to do it… according to the pic you posted, this should work:


    galaxyPath.startNewSubPath(p1);
    galaxyPath.cubicTo(p2, p3, p4);
    galaxyPath.cubicTo(p4, p5, p6);

But it doesn’t… p4 looks like a corner, and not like a curve

Not quite, the path is stateful, so you don’t need p4 in the second segment:

 galaxyPath.startNewSubPath (p0);  // startPoint
 galaxyPath.cubicTo (p1, p2, p3);  // controlPoint1, controlPoint2, endpoint
 galaxyPath.cubicTo (p5, p6, p7);  // already at p3

cubicTo():

Adds a cubic bezier curve from the shape’s last position to a new position.

This will connect the end-point of the last line or curve that was added to a new point, using a cubic spline with two control-points.