Name
MergeLayers -- merge layers into new layer (V10.0)
Synopsis
MergeLayers(layer1[, layer2, ..., t])
Function
This function merges the layers specified by layer1, layer2, etc. into a new layer while preserving the source layers. By default, MergeLayers() will automatically hide the source layers, but this behaviour can be changed by setting the AutoHide tag to False in the optional table argument. Instead of single layers, you can also pass layer groups that should be merged to this function.

The new layer that is created by MergeLayers() will use the special #MERGED layer type. Layers of type #MERGED can't be transformed (except by the layer scaling engine) and they'll typically contain all settings of their child layers, e.g. shadow, border, filters, transparency settings etc. rendered into the layer, although this can be changed using certain tags in the optional table argument. In comparison to layer groups created using GroupLayer(), one advantage of merged layers is that when showing them using transition effects they will be treated as a whole whereas showing layers that are part of a group created by GroupLayer() using transition effects would apply the transitions to each group member individually which might not always look as good as when the transitions are applied to the layers as a whole. This limitation of GroupLayer() can thus be overcome by using MergeLayers().

The optional table argument t can contain the following tags:

AutoHide:
Specifies whether or not the source layers should be automatically hidden by MergeLayers(). By default, MergeLayers() will automatically hide the layers that are merged into a new one. If you don't want that, set this tag to False. Defaults to True.

MergeShadow:
Specifies whether or not any potential layer shadow should be merged into the new layer as well. This defaults to True. If you set this to False, no shadow effect from any of the source layers will be merged into the new layer so the new layer will appear without any shadow. Of course, it's possible to add a shadow to the new layer using SetLayerShadow() or the standard drawing tags.

MergeBorder:
Specifies whether or not any potential layer border effect should be merged into the new layer as well. This defaults to True. If you set this to False, no border effect from any of the source layers will be merged into the new layer so the new layer will appear without any border effect. Of course, it's possible to add a border effect to the new layer using SetLayerBorder() or the standard drawing tags.

MergeFilter:
Specifies whether or not any potential layer filter should be merged into the new layer as well. This defaults to True. If you set this to False, no filter from any of the source layers will be merged into the new layer so the new layer will appear without any filters. Of course, it's possible to add filters to the new layer using SetLayerFilter() or the standard drawing tags.

MergeTransparency:
Specifies whether or not any potential layer transparency should be merged into the new layer as well. This defaults to True. If you set this to False, no transparency from any of the source layers will be merged into the new layer so the new layer will appear without any transparency setting. Of course, it's possible to set the transparency of the new layer using SetLayerTransparency() or the standard drawing tags.

MergeFX:
Specifies whether or not any potential layer transition effect should be merged into the new layer as well. This defaults to True. If you set this to False, no transition effect from any of the source layers will be merged into the new layer so the new layer will appear without any transition effects.

Furthermore, the optional table argument also supports Hollywood's standard drawing tags. See Standard drawing tags for more information about the standard tags that nearly all Hollywood drawing commands support.

Note that merged layers aren't updated automatically when their source layers change their graphics. You need to use the RefreshLayer() function to force an update of a merged layer. See RefreshLayer for details. Also note that only visible layers will be merged. Hidden layers will be ignored by MergeLayers().

You need to enable layers before you can use GroupLayer(). See Layers introduction for details.

Inputs
layer1
first layer or layer group to merge
...
further layers or layer groups to merge
t
optional: table containing further options (see above)
Example
EnableLayers
SetFillStyle(#FILLCOLOR)
SelectBGPic(1)
Box(0, 0, 100, 100, #RED)
Box(100, 0, 100, 100, #GREEN)
Box(200, 0, 100, 100, #BLUE)
MergeLayers(1, 2, 3, {Name = "newlayer", Hidden = True})
MoveLayer("newlayer", #CENTER, #CENTER)
EndSelect
ShowLayerFX("newlayer", #ZOOMCENTER)
The code above creates three hidden 100x100 rectangles, merges them to a new layer, moves this new layer to the center and then shows the merged layer with a transition effect. Note that we use SelectBGPic() to make sure nothing is drawn before our call to ShowLayerFX().

Show TOC