[cairo] can cairo give me a draw pen with gradient width

Carl Worth cworth at cworth.org
Tue Dec 11 10:51:24 PST 2007


On Tue, 11 Dec 2007 14:28:46 +0800, "glorious tao" wrote:
> Hi, I want to use cairo to draw chinese characters,  but how can I get a
> draw pen with gradient width? In a real world, I use bush pen to do some
> handwriting,  when I push harder and move faster, the pen width will become
> thinner, so I can get beautiful handwriting (like in the attachment). so can
> I use cairo to do that, or someone give me some suggestions?

Hi there,

Various other people have already given good answers, but I thought
I'd answer as well here.

First, yes, variable-width stroking is definitely an interesting
operation to want to perform.

Second, the cairo_stroke operation will not provide this in general,
(the closest it can do is give you a fixed elliptical pen throughout
the stroke).

But you can definitely still can draw the shape you want with
cairo. The trick is simply to provide cairo a path that describes the
outline of the shapes you want and then use cairo_fill. This is
precisely the same mechanism that most font systems such as TrueType
use to describe glyph shapes with elements that have the appearance of
variable-width strokes. (Contrast with MetaFONT which does have the
ability to do variable-width strokes I believe.)

Finally, on top of cairo you might very well want to implement a
system that can accept as input a brush path along with brush pressure
and speed, and that would then compute the desired outline to
fill. And once something like that were implemented, it might even
make sense to push it down into cairo.

So do let us know what you come up with, and have fun with cairo!

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071211/67908b34/attachment.pgp 


More information about the cairo mailing list