Exploring canvas drawing techniques
perfectionkills.com
perfectionkills.com
http://codepen.io/anon/pen/EqbnG
My implementation still isn't perfect, as it biases points in the middle over points around the edges. (A consequence of the fact that a bunch of points evenly distributed around a small radius are closer together than a bunch of points evenly distributed around a large radius.) But it's definitely better than the one in the article.
I changed it to
var angle = (Math.PI * 2 * Math.random());
But it has your problem as well. To be fair, a spray can also focuses the paint in the center like that :)This means there's nothing special about 3 - the more times you add uniforms together, the more normal it becomes. Also it doesn't matter if the uniform isn't uniform.
I should really update it to add controls for mass and friction. Actually I should make a jsfiddle for this. But, I'm in the middle of something else at the moment..
Using Bézier curves, but with variable width, can give nice "handwritten" feel to it - http://szimek.github.io/signature_pad (works best on touch devices).
Not saying the author of that pad is evil or anything, I just questioned my own impulse. And stopped drawing. :)
Good idea though, I'll have to add form for credit card details :)
When you start adding in the flexibility of different tool types, differentiating "stroke" and "material", real-time preview vs. final, and other nuances, the internals start to resemble a dataflow system dealing with point paths and canvas buffers. Often you take raw input and derive a new path from it, or take an existing buffer and combine it with path data.
The basic rendering techniques really are this straightforward, it's just the flexibility requirement that adds complication.
I went through the code for each, starting with the simplest and working my way up to the much more interesting and complex.
The only thing missing is a way to edit the JS and see the result. Looks like it's easy to use an embedded jsfiddle[0], but I have not tried it myself.
If you look on at the right edge of the grey-ish tab bar, you will see an "edit" link. This opens up a link to CodePen which lets you fork the snippet and mark changes to it. Here is one such link: http://codepen.io/kangax/pen/wDuxl
[0] - http://www.amazon.com/Knowledge-Adventure-Spider-Man-Cartoon...
Now, that in mind, there are limitations and especially for drawing applications it's a shame that you have to think that hard about how to antialias a stroke (approximating it with shadows – really?). So in a way we dragged 2D graphics to the web, but leaving it with a strange mixture of features which date from a range of 1980–2000.
this is a nice example of what i like about programming most visualizations in general. it's fun and easy to brainstorm. change variables and logic until you end up with something you like.