[cairo] Drop Shadow Effect
Cxx Joe
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:
> Hi,
>
> The example here
> http://kalaalog.com/2008/06/15/drop-shadows-in-inkscape/
> 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:
http://mxr.mozilla.org/mozilla2.0/source/gfx/thebes/gfxBlur.cpp
I adapted that code like this:
http://code.google.com/p/infekt/source/browse/trunk/src/lib/cairo_box_blur.cpp
which makes it easy to use (pseudo code):
b = new CCairoBoxBlur();
RenderMyStuff(b->GetContext());
cr = cairo_create(final_surface);
b->Paint(cr);
RenderMyStuff(cr);
Hope this helps.
Joe
More information about the cairo
mailing list