[cairo] Bevel Effect

Theo Veenker T.J.G.Veenker at uu.nl
Sun Nov 21 11:17:24 PST 2010

On 11/20/2010 07:46 PM, Jeremy Moles wrote:
> Hey guys--I'm looking for some help here.
> I've been searching, fruitlessly, for an algorithm that will allow me to
> perform a bevel effect in C or C++ code to simple raw image data. I've
> looked through gimp source, ImageMagick source, and anything else I
> could find on Google.
> I was wondering if anyone here had any advice or any ideas about how I
> could implement this? Specifically, I will be using it in Cairo to apply
> a bevel effect to text. Is this something that could be achieved PURELY
> in Cairo, or would I need to manipulate the image data directly?
> Any help or advice would be appreciated. What I'm going for is
> essentialy the same functionality gimp provides in it's
> "Scripts->Decor->Apply Bevel" script.

In addition to Steve's suggestion, if it's for non-rotated rectangular things
like buttons, you could make the top/left edge lighter by drawing them in white
with alpha increasing from say 0.5 (outer edge) to 1 (inner edge) and something
reverse for the bottom/right edge. That way your bevels keep the same color
as the surface, if that's what you want. See attachment for someting to play

I suspect the best approach would be to draw a rectangle (or any other outline)
on top of the target surface using a conical (or mesh) stroke pattern. Do I
make sense? Unfortunately cairo doesn't support conical patterns yet AFAIK.
Maybe someone can show bevels created with the aid of gradients?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: borders.c
Type: text/x-csrc
Size: 13460 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101121/d70c4f41/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image-raised.png
Type: image/png
Size: 7121 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101121/d70c4f41/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image-sunken.png
Type: image/png
Size: 5838 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101121/d70c4f41/attachment-0003.png>

More information about the cairo mailing list