[cairo] cairo-1.13 finally opens

Krzysztof Kosiński tweenk.pl at gmail.com
Sat Sep 7 06:43:29 PDT 2013


2013/9/7 Bill Spitzak <spitzak at gmail.com>:
> Krzysztof Kosiński wrote:
>
>>> Inset shadow
>
>
>> Why not:
>> cairo_fill_preserve(cr);
>> cairo_clip_preserve(cr);
>> cairo_set_blur(...);
>> cairo_set_source(...); // change shadow color
>> cairo_fill(cr);
>
>
> The path/mask has to be inverted as well so the color is put against the
> edges, not in the middle. This can be done either before or after the blur.

Inset shadow means that the shadow is inside the shape, e.g. it has to
be clipped to the original shape. For normal shadow, there is no need
to clip:

cairo_save(cr);
cairo_set_blur(...);
cairo_set_source(...); // shadow color and opacity
cairo_fill_preserve(cr);
cairo_restore(cr);
cairo_fill(cr);

There are two potential problems with this simplified API:

1. Currently there seems to be no way to modify the path on the
context, for example to add an offset, so for offset shadows the path
would have to be processed twice.

2. Optimizing the rendering of a drop shadow under a large opaque
object might be more difficult. On the other hand, I'm not sure there
is a lot to gain in this case.

Regards, Krzysztof


More information about the cairo mailing list