2D brush algorithms

This topic is 2767 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi,

I am looking for algorithms to draw lines, like this one (e.g. with the fading effect around the boarder; ideally also with some extend of smearing):

Where can I find such algorithms? Examples with source code would be fine, but papers are ok too.

Thanks,

Share on other sites
Typically, it works like this, as far as I can tell:

Your curve has an alpha channel, which is formed,

For each pixel of one-pixel-wide-curve   Draw brush shape to alpha channel, with commutative blending.

By commutative blending I mean additive or multiplicative, depending on the effect you want.

For the brush shape, you have various options. Pre-baked sprites are one option. Various mathematical functions work too. In the latter category, I like the "poly6 kernel" myself. That's,

       /k(p) = | (1 - ||p||^2/R^2)^3    if  ||p|| < R       | 0                      otherwise       \

None of this includes any smearing; for that you'll need something fancier. But this is what e.g. GIMP and Photoshop seem to do.

Share on other sites
E.g. use a gauss filter for the blur effect - thats easy - just google it. The curve shape can be done using splines, like b-splines or beziers.

Share on other sites
it's a real-time effect; the user draws something and instantly the curve below the pen should look similar to the example above. Thus I will follow "Emergent's" suggestions.

Thanks!

• 10
• 16
• 14
• 18
• 15