Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!