SelectAlphaChannel -- select an alpha channel as output device (V2.0)
SelectAlphaChannel(id[, type, frame])
This function selects the alpha channel of the graphics object specified by id as the current output device. This means that all graphics data that are output by Hollywood will be drawn to this alpha channel. Alpha channels are no stand-alone objects in Hollywood; they are always attached to an image object, for example a brush or an animation.

By default, SelectAlphaChannel() always works with the alpha channels of brushes. However, starting with Hollywood 4.5, you can also use it to draw to the alpha channel of animations and BGPics. To do this you have to specify #ANIM or #BGPIC in the optional type argument. If you use #ANIM in the type argument, you have to specify the frame of the anim that you want to draw to, too. See SelectAnim() for more information. If you specify #BGPIC in type, note that you can only modify the alpha channel of BGPics that are currently not associated with a display. Starting with Hollywood 4.7, you can also pass #LAYER as the type to modify the alpha channel of a layer. Note that if the layer is an anim layer, you will also have to specify the number of the frame to select.

Alpha channels can be used to give each pixel its own transparency setting. There are 256 different transparency levels available for each pixel. An alpha channel value of 0 means that the pixel is fully transparent and an alpha channel value of 255 means that the pixel is opaque. All Hollywood graphics functions will render with a static alpha channel intensity into the alpha channel of the graphics object. You can configure this intensity using the SetAlphaIntensity() command. Alternatively, you can set the alpha render mode to a vanilla copy mode. This is done by calling SetAlphaIntensity() with #VANILLACOPY as the argument. Then, all Hollywood graphics commands which output alpha channel pixels will copy the exact alpha channel data to your brush's alpha channel. This vanilla copy mode is a new feature of Hollywood 2.5.

The color argument that several Hollywood functions (like Box() or Circle()) expect, is superfluous when rendering to alpha channels. You only need to use SetAlphaIntensity() when rendering to alpha channels.

Alpha channels are usually used for nice background shine-through effects or for anti-aliasing jagged edges. If you do not need different transparency levels but only two choices, namely transparent pixels and opaque pixels, you should use SelectMask() instead because it can be drawn faster. Please note that graphics objects cannot have a mask and an alpha channel. Only one transparency setting is possible. Thus, if you use this command on a graphics object that has a mask, this mask will be deleted first.

If the graphics object you specify in id does not have an alpha channel yet, it will be automatically created when you call a command that wants to draw to the alpha channel. The alpha channel created will be opaque then, i.e. every pixel will have an alpha intensity of 255 which means that it is 0% transparent. To cancel alpha channel rendering mode and return to main display output, just call the EndSelect() function.

If you do not need an alpha channel any longer, you should use the command DeleteAlphaChannel() to remove it from the brush.

You cannot use brush links with this command because the graphics data of the brush specified by id will be changed. It is also forbidden to call commands which change the dimensions of the brush/anim that is currently used as output device, e.g. you may not call ScaleBrush() or ScaleAnim() to scale the brush/anim that is currently the output device. Furthermore, it is not allowed to call SelectAlphaChannel() for animations that are loaded from disk. Animations must always reside completely in memory if you want to draw to their frames using SelectAlphaChannel().

Only commands that output static graphics can be used when SelectAlphaChannel() is active. You may not call animated functions like MoveBrush() or DisplayBrushFX() while SelectAlphaChannel() is active.

If you are using type #LAYER and the specified layer is a vector layer, SelectAlphaChannel() will rasterize the layer to a brush layer first. See SelectLayer for details.

graphics object whose alpha channel shall be used as output device
optional: type of the graphics object specified in id; can be #BRUSH, #ANIM, #BGPIC, or #LAYER (defaults to #BRUSH) (V4.5)
optional: animation frame to use; only required if type is set to #ANIM or #LAYER in case the specified layer is an anim layer (V4.5)
CreateBrush(1, 256, 50, #RED)    ; create a brush of size 256x50
SelectAlphaChannel(1)            ; alphachannel becomes output device
For k = 255 To 0 Step -1
   SetAlphaIntensity(k)          ; set alpha intensity to k
   Line(255 - k, 0, 255 - k, 49) ; draw lines with various intensities
EndSelect                        ; make display the output device again

DisplayBrush(1, #CENTER, #CENTER)
This code demonstrates the 256 different transparency levels by creating a brush with the width of 256 pixels and drawing 256 lines with different transparency settings into it. The result will be a red rectangle which smoothly merges with the background picture. Please note that you need a 24-bit screen for the full eye-candy. On 15-bit and 16-bit screens there are not enough colors to display all different levels.

Show TOC