Drawing application

Hi,

I’m trying to do a drawing application with OF, so when you move your mouse it should look like you are painting on the screen.
I’m trying to start off by doing this with a polyline in hopes it will at least look like a pen drawing. so far it’s one straight line that follows your mouse but it does not curve. I’ve also been using ofpath but not sure which one is better for what I want to do.I’m hoping someone can point me in the right direction. Thanks

  
ofPolyline myline;  
    myline.addVertex(start.x,start.y);  
    myline.curveTo(mouseX,mouseY);  
    myline.bezierTo(mouseX,mouseY, mouseX,mouseY,mouseX, mouseY);  
    myline.addVertex(end.x,end.y);  
   myline.draw();  

The start and end vectors are mouse positions.

I think the first thing you will need to do is to store mouse positions to have a last mouse position and the current mouse position. Like these you can calculate mouse directions and velocity. Now in the piece of code you post only use current position.

And then you will have to play to archive a nice rendering. Look in forum these is a topic many people had look. Here one old post talking about paint brush: http://forum.openframeworks.cc/t/how-to-create-a-painting-brush/3144/0

Dedre you may also check this repository.

https://github.com/ofZach/drawing-examples

I think it´s from a Workshop Zach Lieberman gave at Eyeo 2012 about creating drawing apps with openFrameworks. It has really nice progressive examples, from basic an more complex ones. I found the examples really useful.

Best,

P.

Oh great! thanks:)