Name
SelectLayer -- select layer as output device (V4.7)
Synopsis
SelectLayer(id, [, mode, frame, combomode])
Function
This function selects the specified layer as the current output device. This means that all graphics data that is rendered by Hollywood will be written to this layer. When EndSelect() is called, the layer will be refreshed automatically to reflect the changes you made to it. You have to specify a layer identifier in the first argument. If that layer is an anim layer, you will also have to specify the frame you would like to select in the third argument.

The optional mode argument defaults to #SELMODE_NORMAL which means that only the color channels of the layer will be altered when you draw to it. The transparency channel of the layer (can be either a mask or an alpha channel) will never be altered. You can change this behaviour by using #SELMODE_COMBO in the optional mode argument. If you use this mode, every Hollywood graphics command that is called after SelectLayer() will draw into the color and transparency channel of the layer. If the layer does not have a transparency channel, #SELMODE_COMBO behaves the same as #SELMODE_NORMAL.

Starting with Hollywood 5.0 you can use the optional combomode argument to specify how #SELMODE_COMBO should behave. If combomode is set to 0, the color and transparency information of all pixels in the source image are copied to the destination image in any case - even if the pixels are invisible. This is the default behaviour. If combomode is set to 1, only the visible pixels are copied to the destination image. This means that if the alpha value of a pixel in the source image is 0, i.e. invisible, it will not be copied to the destination image. Hollywood 6.0 introduces the new combomode 2. If you pass 2 in combomode, Hollywood will blend color channels and alpha channel of the source image into the destination image's color and alpha channels. When you draw the destination image later, it will look as if the two images had been drawn on top of each other consecutively. Please note that the combomode argument is only supported together with #SELMODE_COMBO. It doesn't have any effect when used with the other modes. Please note that the combomode argument is only supported together with #SELMODE_COMBO. It doesn't have any effect when used with the other modes.

An alternative way to draw into the transparency channels of a layer is to do this separately using SelectMask() or SelectAlphaChannel(). These two commands, however, will write data to the transparency channel only. They will not touch the color channel. So if you want both channels, color and transparency, to be affected, you need to use SelectLayer() with mode set to #SELMODE_COMBO.

When you are finished with rendering to your layer and want to use your display as output device again, just call EndSelect(). If your layer is visible, Hollywood will refresh it automatically now to reflect the changes you made to it. It is important to take into account that your changes won't be visible before you call EndSelect().

Note that you must not call any commands which modify your layer while it is selected as the output device. For example, you must not call SetLayerStyle() or RemoveLayer() while it is the output device.

Only commands that output graphics directly can be used after SelectLayer(). You may not call animated functions like MoveAnim() or DisplayBrushFX() while SelectLayer() is active.

Please note that if you use this command on a vector layer (for example a polygon or text layer), the layer will get rasterized automatically. This means that, effectively, the former vector layer will now be a brush layer. The difference between the two is only visible when it comes to transforming the layer: A vector layer can be freely transformed without any losses in quality. A rasterized brush layer, on the other hand, will always have losses in quality when it is transformed.

Inputs
id
layer which shall be used as output device
mode
optional: rendering mode to use (see above); this can be either #SELMODE_NORMAL or #SELMODE_COMBO; defaults to #SELMODE_NORMAL
frame
optional: in case the specified layer is an anim layer, this argument specifies which frame to select (first frame=1)
combomode
optional: mode to use when #SELMODE_COMBO is active (see above); defaults to 0 (V5.0)
Example
SelectLayer(1)
SetFillStyle(#FILLCOLOR)
Box(0, 0, 320, 256, #RED)
EndSelect()
The code above draws a 320x256 rectangle to layer 1.

Show TOC