views:

55

answers:

1

stroke() in Cairo applies a stroke of a single specified width to a line path.

I'd like to draw a path with a varying width (thinner when the user was drawing faster, thicker when slower). Is this possible in Cairo?

A: 

Use cairo_set_line_width to set it and "split" the path in more than one piece. Unluckly as you noticed cairo_set_line_width is the width for the whole current path (since it sets the attribute as if you are choosing a pen to draw that path): cairo_set_line_width

«As with the other stroke parameters, the current line width is examined by cairo_stroke(), cairo_stroke_extents(), and cairo_stroke_to_path(), but does not have any effect during path construction.»

ShinTakezou
This would get very inefficient for the kind of drawing I want to do, which is very smoothly varying line width. With this approach, I would be drawing as many line segments as the line is pixels long.
alexbw
Then I believe cairo is not what you need... If you need calligraphics effect, some other kind of drawing facility is needed; indeed I suspect you've to do it yourself. But consider also this solution: to draw the "contour/border" and fill, instead! --- ops forget you follow user input... but if it so, the slowness of the prev. method is so unacceptable?
ShinTakezou