How does inkscape vectorize a brush stroke?

General discussions about Inkscape.
Flintlock
Posts: 1
Joined: Fri Jul 03, 2009 8:34 am

How does inkscape vectorize a brush stroke?

Postby Flintlock » Fri Jul 03, 2009 8:51 am

I want to program a 2D animation tool that works somewhat like Toon Boom. I was sitting in math class this morning (not paying attention) and it dawned on me how Toon Boom, and as far as I can tell Inkscape, handles brush strokes. It appears to me that the brush sets pixels in raster format, like a typical paint program would, and then when the mouse button is released or the stylus pressure reaches zero, the pixels are vectorized. I know there are programs out there that can vectorize raster graphics, but I can't find any examples of how to program it.

Am I correct that Inkscape vectorizes raster brush strokes? If not, how does it work? If so, where can I learn how to make my program do that? Thanks.

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: How does inkscape vectorize a brush stroke?

Postby microUgly » Mon Jul 27, 2009 3:36 pm

I don't know, but I didn't think that Inkscapes brush uses raster and converts to vector ( :tool_paintbucket: does though). But if it does, it's using this code http://potrace.sourceforge.net/

User avatar
tomh
Posts: 218
Joined: Sat Feb 14, 2009 10:14 pm

Re: How does inkscape vectorize a brush stroke?

Postby tomh » Tue Jul 28, 2009 7:58 am

No, this is not how Inkscape creates a brush stroke. the only place that vectorising via potrace is used is by the fill bucket tool ( :tool_paintbucket: ) or by path->trace bitmap.

Assuming that when you say "brush strokes" you mean the calligraphy tool ( :tool_calligraphic: ) how it works (or at least how I *think* it works as I am not a developer) is by recording the mouse position after a time interval, along with the width needed as determined by the width setting, tracing setting and stylus pressure. It then takes two points normal to the direction of movements and adds the control points there. Have a look for yourself while using the :tool_calligraphic: tool. you will see the previous line drawn and then a red section which represents the last section of the path recorded.

If you meant how the pencil tool :tool_pencil: works, I don't really know, but I think it records a list of mouse positions, then depending on smoothness settings, will fit a line between them. Something like how "connect the dots" drawings work, although this is all guesswork really 8-) If you need anymore, have a look at http://inkscape.svn.sourceforge.net/vie ... iew=markup or the draw context stuff in the source control...

Hope that helps, and I hope I haven't got anything *too* wrong


Return to “General Discussions”