CreateLayer -- create a new layer (V4.7)
CreateLayer(x, y, width, height[, table])
This command can be used to insert a new layer to the current BGPic. The layer will be of the dimensions specified in width / height and it will appear at the specified position. This function will create either a layer of type #BRUSH or of type #ANIM. If you want to create an anim layer, you will have to pass the desired number of frames in the Frames tag in the optional table argument.

The optional table argument recognizes the following tags:

Specifies the number of frames for this layer. If this is set to 1, CreateLayer() will create a brush layer. Otherwise an anim layer containing the specified number of frames will be created. Defaults to 1 (which means that by default, CreateLayer() will create a brush layer).

Specifies the initial RGB color of the layer. This defaults to $000000 (i.e. black).

Set this tag to True if CreateLayer() should attach a mask to the new layer. If this is True, AlphaChannel must be False. Defaults to False.

Set this tag to True if CreateLayer() should attach an alpha channel to the new layer. If this is set to True, Mask must be set to False. Defaults to False.

This tag is only handled if either AlphaChannel or Mask was set to True. If that is the case, Clear specifies whether or not the mask or alpha channel should be cleared (i.e. fully transparent) or not (i.e. opaque). This defaults to False which means that by default, the new mask or alpha channel will be opaque.

Additionally, you can pass one or more of the standard tags in the optional table argument. Using these tags you can for instance control the insert position of the layer, assign a name to it, and modify the anchor point settings of this layer. See Standard draw tags for details.

CreateLayer() is the preferred way of creating an empty layer that you later want to modify using the SelectLayer() command. Of course, you could also create an empty brush using CreateBrush() and then insert it as a layer using DisplayBrush() or InsertLayer() but this is not as effective as using the new CreateLayer() function because when you then call SelectLayer() on a layer that was created from an existing brush source, Hollywood first has to create a copy of the layer because SelectLayer() shall only modify the layer contents and not the contents of the brush that was used to create the layer. This is not very critical with brush layers, but imagine an anim layer with some dozens of frames! Using SelectLayer() on such an anim layer would be very expensive and would take quite some time. In these cases, CreateLayer() is really much more effective.

desired x position for the new layer
desired y position for the new layer
desired layer width
desired layer height
optional: table configuring further options; can be one or more of the tags listed above or from the standard tags
CreateLayer(#CENTER, #CENTER, 100, 100, {Color = #RED})
Circle(0, 0, 50, #WHITE)
The code above creates a new 100x100 red layer and then draws a white circle onto it.

Show TOC