14

I'm trying to write an application that can be used to create pictures that look like paintings using simulated brush strokes. Are there any good sources for simple ways of simulating brush strokes? For example, given a list of mouse positions that the user has dragged the mouse through, a brush width and a brush texture, how do I determine what to draw to the canvas?

I've tried angling the brush texture in the direction of the mouse movement and dabbing several brush texture images along the path, but it doesn't look great. I think I'm missing something where the brush texture should shrink and grow on corners.

Any simple to follow links would be appreciated. I've found complex academic papers on simulating e.g. oil paints but I just want a basic algorithm to use that produces OK results if possible.

DrRobot
  • 175
  • 1
  • 6
  • In addition to the coordinate list, can you get timestamps? That might let you darken the runs where the user was drawing slowly or hesitating. – genpfault Jun 18 '10 at 04:25
  • to properly simulate a brush behavior realistically, you'll at least need to know this information: coordinate list, pressure, speed, and pen/brush angle. A regular mouse can only collect data about coordinate list and speed; you need a wacom tablet to gather pressure and maybe angle. You may want to look at how "Inkscape" does its brush tool, which does a pretty good job for a mouse-only drawing. – Lie Ryan Jun 18 '10 at 19:24

5 Answers5

8

There's a large literature on Non-Photorealist Rendering. The main books are "Non-Photorealistic Computer Graphics" by Strothotte & Schlechtweg and "Non-photorealistic Rendering" by Gooch & Gooch. They discuss brush strokes. There are several of papers that deal with simulated brush strokes. See for instance "Simulating Artistic Brushstrokes Using Interval Splines".

manlio
  • 18,345
  • 14
  • 76
  • 126
lhf
  • 70,581
  • 9
  • 108
  • 149
  • 2
    The link for Gooch is broken. [Alternate Link](http://www.cs.northwestern.edu/~ago820/book.html) – R D Dec 01 '16 at 15:31
7

Here's a classic from 1989 - Dynadraw, by Paul Haeberli. It uses a simple dynamical model to fill in a smooth the raw mouse positions.

While the strokes are drawn incrementally as polygons, you should be able to use the points generated by the dynamic filter to place copies of your brush texture.

brainjam
  • 18,863
  • 8
  • 57
  • 82
  • Thanks, this looks interesting! I'm curious if there is a similar algorithm specifically for paint strokes. – DrRobot Jun 18 '10 at 02:42
  • @DrRobot, I'm not sure what you mean by that. Dynadraw *is* specifically for paint strokes, no? – brainjam Jun 18 '10 at 13:33
  • Oops, I thought it was a simulation of a pen-like tool... :-/ Thanks. – DrRobot Jun 18 '10 at 17:27
  • @DrRobot, fair enough, it's pen-like. But as I said, should be easy to convert to brush-like. – brainjam Jun 18 '10 at 17:39
  • @brainjam I know this code and this thread are both old so who knows if I will get a response but what is the "IRIS" mentioned on the site with the source code? It it says "You can save this onto your IRIS, compile it", may be missing something very simple here or too young to know what that means. – LukeS Mar 17 '14 at 20:57
  • 1
    The stackoverflow bat signal is in good working order. "Iris" was a graphics workstation sold by Silicon Graphics (SGI) back in the day. See http://en.wikipedia.org/wiki/SGI_IRIS for example. – brainjam Mar 17 '14 at 21:17
0

The way I can think of would be to figure out the strength of the brush at each point in the line, and layer many uniform textures over it. Each texture would have an alpha value corresponding to "how hard" the brush is pushing down on the canvas at that location. The function to figure out how hard the brush would be pushing down would probably have to be correlated with the input.

If you go into a tool like Photoshop or GIMP, and observe how it implements the paintbrush tool, it should be pretty easy to simulate something close to it.

Andrei Krotkov
  • 5,556
  • 3
  • 33
  • 36
  • I've really copied what gimp has at the moment and gimp doesn't seem to do paint simulation well at all. I've already got settings for opacity and spacing and the angle of the stroke follows the mouse. Cornering doesn't look right as the brush shape doesn't change, just like in gimp. – DrRobot Jun 18 '10 at 02:44
0

Not exactly what you're asking for, but I've found that applications that use line smoothing (like Adobe Ideas on the iPad or Doozla on the Mac) make for more realistic and eye-pleasing brush strokes, as you don't get the un-natural "jaggies" associated with tracking mouse movements perfectly.

Martin Cron
  • 1,154
  • 1
  • 8
  • 10
0

not as a programmer but as an artist and an avid reader I have the following suggestion: use the image "subtractively" from a solid line. Not additive as if its own line. By doing this you preserve corners as they already exist and then the negative space of the image will effect the texture of the line over all. No more jagged corners and the line looks smoother.

Also I like the idea presented by the article "Simulating Artistic Brushstrokes Using Interval Splines" linked by Manilow (THANK YOU!): "Hsu et al. introduced “skeletal strokes”, deformable images that can be anchored, scaled, or transformed by multiple factors at each control point"

I think this is the best way to handle sharp turns. Think of those old word art things where you could adjust arches and curves in them and the text would conform to that, but with a texture image. As an artist I am grateful for anyone not satisfied with cheezy "traincar" lines. Thank you all.

BLIRTT
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 28 '23 at 14:10