Monday 15 September 2014

Drawing application with OpenGL/Openframeworks -


I am trying to program a brush stroke / drawing application using OpenGL within Openframeworks. For now I'm just trying to make clever lines that follow my mouse.

I have started using the polynines but I have managed to create a straight line that follows my mouse. I will actually tell some pseudo code or something in the right direction. Start Set (MouseX, Mousse); End.set (mouseX, shear); Polylinelineline; Myline.addVertex (start.x, start.y); Myline.curveTo (end.x, end.y); Myline.bezierTo (mousex, mouse, mxax, mousse, mousex, mousse); Myline.addVertex (end.x, end.y); Myline.draw ();

A bezier curve with two vertex is always a straight line segment, non-degenerate You need to add more meridians / control points in order to achieve (round) curves. So you can store the position of the last mouse anywhere, and add a new top when the mouse was moved from a certain amount (such as 20 pixels). Or add a head while clicking the user. However, if you always say Bezier to (X, Y, X, Y, X, Y), you will still get straight lines. To get round curves, you need to offset two control points offset (X, Y).

No comments:

Post a Comment