Implementing a scribbler algorithm
In this recipe, we are going to implement a scribbler algorithm, which is very simple to implement using Cinder but gives an interesting effect while drawing. You can read more about the concept of connecting neighbor points at http://www.zefrank.com/scribbler/about.html. You can find an example of scribbler at http://www.zefrank.com/scribbler/ or http://mrdoob.com/projects/harmony/.
How to do it…
We will implement an application illustrating scribbler. Perform the following steps to do so:
Include the necessary headers:
#include<vector>
Add properties to your main application class:
vector <Vec2f> mPath; float mMaxDist; ColorA mColor; bool mDrawPath;
Implement the
setup
method, as follows:void MainApp::setup() { mDrawPath = false; mMaxDist = 50.f; mColor = ColorA(0.3f,0.3f,0.3f, 0.05f); setWindowSize(800, 600); gl::enableAlphaBlending(); gl::clear( Color::white() ); }
Since the drawing will be made with the mouse, it is necessary to use...