Name
CreateBrush -- create a blank brush (V1.5)
Synopsis
[id] = CreateBrush(id, width, height[, color, table])
Function
This function creates a new brush in the specified dimensions and initializes it to the specified color. If no color is specified, the brush is initialized to black. If you specify Nil in the id argument, CreateBrush() will automatically choose a vacant identifier for this brush and return it to you.

Starting with Hollywood 4.5, there is an optional table argument which you can use to create a mask or an alpha channel for this brush. The following tags are recognized by the optional table:

Mask:
Set this tag to True if CreateBrush() should attach a mask to the new brush. If this is True, AlphaChannel must be False. Defaults to False.

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

Clear:
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.

Hardware:
If you set this tag to True, Hollywood will create this brush entirely in video memory for hardware-accelerated drawing in connection with a hardware double buffer. Hardware brushes are subject to several restrictions. See hardware brushes for details. (V6.0)

Display:
If you specify the identifier of a display here, Hollywood will create a display-dependent hardware brush for you. Display-dependent hardware brushes can only be drawn to the display they belong to. This tag is only handled if the Hardware tag has been set to True. Also note that Hollywood's inbuilt display adapter does not support display-dependent hardware brushes, but plugins can install custom display adapters which support display-dependent hardware brushes. This tag defaults to the identifier of the currently active display. See hardware brushes for details. (V6.0)

SmoothScale:
If you set this tag to True and the Hardware tag has also been set to True, Hollywood (or display adapters) will use bilinear interpolation when transforming this brush. Normally, whether interpolation shall be used or not is set when calling a brush transformation command like ScaleBrush() or RotateBrush() but some display adapters need to know this information already at the time a hardware brush is created, and this is why this tag is here, though it's probably of not much use because it's only needed in rather special situations with display adapters like RebelSDL or hardware brushes on Android, because normally you can just specify whether interpolation shall be used or not in the transformation command directly. Note that SmoothScale is only supported when Hardware is set to True. (V8.0)

Inputs
id
id for the new brush or Nil for auto id selection
width
width for the brush
height
height for the brush
color
optional: RGB color for background (defaults to #BLACK)
table
optional: table for specifying further options (see above) (V4.5)
Results
id
optional: identifier of the brush; will only be returned when you pass Nil as argument 1 (see above)
Example
CreateBrush(2, 320, 256, #BLUE)
The above code creates a new blue brush with the id 2 and the dimension of 320x256.


CreateBrush(2, 320, 256, #BLUE, {AlphaChannel = True, Clear = True})
The code above creates a new blue brush with id 2 in a size of 320x256. The new brush will also get an alpha channel that will be set to 100% transparent. Thus, if you display the new brush, you will see nothing because the brush is currently fully transparent.

Show TOC