Using the “combine” attribute in the <layer> and <merge> elements

“Combine” in FSDL is an attribute that must be present within every <layer> element, as well as every <merge> element. Since “combine” effects <layer> and <merge> elements identically, I’m only going to refer to the <layer> element in this post, for example:

<layer combine='add' resref='photo_r' layerid='photo_l' leapout='vignette' pos='0,0' align='top-left' />

The “combine” attribute determines how the alpha channel (transparent parts) of one layer can effect those of other layers. It can be very useful for getting the most out of a small number of graphic resources.

The four possible values for the “combine” attribute are “add,” “clip,” “cutout” and “inter.”

Let’s look at each one individually.

Add

When the value of a “combine” attribute is “add,” the result is that the alpha channel of its <layer> will have no effect on that of the layers beneath it.

Imagine that we have three layers: a red square, a blue circle and a green circle, and the green circle is on top of the other two:

combine_add_01

The “combine” attribute of the green circle has a value of “add,” and its alpha channel (which makes the areas outside of its round shape transparent) has no effect on the other layers.

Clip

When the value of a “combine” attribute is “clip,” the result is that the alpha channel of its <layer> will inherit those  of the layers beneath it.

So, if in the previous example, the green circle layer had a “combine” attribute of “clip,” it would inherit the transparencies of the other two layers. In other words, it would only be visible in the zones where either of the other two layers are also visible:

combine_clip_01

You might use this effect, for instance, to put a person in front of a photo such that he or she appears to be cropped within the photo’s boundaries.

clip_van_gough

Cutout

When the value of a “combine” attribute is “cutout,” the result is that the alpha channel of the layer in front is subtracted from the alpha of the layer behind.

It’s as if the layer in front were used to cut a hole in the layer behind. The layer in front is invisible, but it also makes the layer behind invisible where its alpha intersects with the layer behind.

So, if the green circle layer in the above examples had a “combine” value of “cutout,” it would be as if the shape of the green circle were “cut out” of the other two layers:

combine_cutout_01

You might use this effect, for instance, to cut a window-shaped hole in a picture of a house. That way the layer that is behind the house looks like it’s inside the house.

cutout_van_gough

Inter

When the value of a “combine” attribute is “inter,” the result is that layers below are only visible where they intersect with the visible areas of the top layer.

It’s as if we took the form of the top layer (having a “combine” value of “inter”) and erased everything that did not pass within the boundaries of  its shape. The colors in the top layer itself are not visible. Using the same layers as in the examples above and giving the top layer (green circle) a “combine” attribute value of “inter,” we get:

combine_inter_01

You might use this effect, for instance, to take a shape, like a string of paper dolls, and fill it with a texture (where the texture is the lower layer that shows within the shape of the paper dolls).

inter_van_gough

Be the first to comment

Leave a Reply

Your email address will not be published.


*