[cairo] Drop Shadow Effect
cxxjoe at googlemail.com
Sun Sep 26 11:29:26 PDT 2010
On Sun, Sep 26, 2010 at 8:15 PM, Prashant Saxena <animator333 at yahoo.com> wrote:
> The example here
> shows how to create drop shadow effect in vector drawing program 'Inkscape'. Is
> it possible to achieve similar
> effect in cairo. In example 'Fill' and 'Stroke' looks similar of cairo but I
> don't know if 'Blur' is available.
It's definitely possible. What you are looking for is a Gaussian Blur:
- Draw the object(s) you want shadowed
- Apply Gaussian Blur
- Draw the object(s) again
A real Gaussian blur however is pretty expensive (in terms of CPU
time). Applying a box blur three times yields a very close result.
Mozilla is achieving this in Firefox with cairo_mask_surface:
I adapted that code like this:
which makes it easy to use (pseudo code):
b = new CCairoBoxBlur();
cr = cairo_create(final_surface);
Hope this helps.
More information about the cairo