How to create a curve line tool?

Hello, I am currently making an openFrameworks project where it acts as an illustrator program such as paint/adobe illustrator on a much simpler scale.

So far, I have normal brush tool where I use ofFbo , and then a straight line tool using the ofDrawLine function. I got these working pretty easily but it seems that for a curve line tool it might be a bit more advanced to my knowledge.

I saw some other threads mention the use of ofPath and curveto but I’m not really sure how to implement it in the way I need it. For example: You click on two different spots and it creates a straight line, and using some other input you can adjust the curve of the line between the two points. Any idea on how to approach this? Thanks

Hey @Hachem24 , maybe have a look at the ofPolyline class. It has a couple of curve-related functions (.curveto() and .bezierTo()) that might be helpful. The curves have 1 beginning point, 1 end point, and various control points that determine the curvature. .curveTo() makes a catmul rom curve; .bezierTo() creates a Bezier one. If you haven’t already, look at the Drawing Lines and Graphics chapters of ofBook. Also the documentation pages for ofPolyline::curveTo() and ::bezierTo() are quite helpful.

It might work well if you ordered all of these points in a std::vector, and re-generate the ofPolyline from them when one of them changes.