Name
SetLayerStyle -- change the style of one or more layers (V4.0)
Synopsis
SetLayerStyle(id1, style1, ...)
Function
This command can be used to modify nearly all attributes of one or more layers or layer groups with a single call. It is a very powerful command which can be used to realize complex animation mechanisms in a very easy and straightforward way. For each layer or layer group whose style you want to modify, you always have to pass the layer or group id followed by a table containing the attributes you want to change. You can repeat this pattern as many times as you need it.

The configuration of the style table depends on the type of layer specified. However, some style elements can be used with all layer types. These generic layer styles will be covered first. The specific layer styles dependent on layer type will be dealt with below.

The following style elements are generic and can thus be used with every layer:

X,Y
Specifies the position for the layer. If not specified the layer will keep its current position.

Width,Height
Can be used to scale the layer to new dimensions. This can either be a numerical value specifying a new pixel size or a string containing a percent specification (e.g. "50%"). See ScaleLayer for details.

Rotate
This style element can be used to control layer rotation. You have to pass a value in degrees here. A positive value means anti-clockwise rotation, negative values rotate in clockwise direction. See RotateLayer for details..

SmoothScale
Specifies whether or not smooth scaling and rotation shall be used on this layer. This is only applicable for non-vector layers and of course it only makes sense when the layer is scaled or rotated.

Transparency
Use this style element to modify the transparency setting of a layer. This can be either a value ranging from 0 (= no transparency) to 255 (= full transparency) or a string containing a percent specification (e.g. "50%" which means half transparency). See SetLayerTransparency for details.

Tint
Use this style element to modify the tint setting of a layer. This can be either a value ranging from 0 (= no tinting) to 255 (= opaque tinting) or a string containing a percent specification (e.g. "50%" which means half tinting). If this is set to non zero, the layer will be tinted with the color specified in TintColor at the specified level. See SetLayerTint for details.

TintColor
Specifies the color to use for tinting. Can only be used in union with the Tint style element.

Hidden
You can use this style element to show or hide the specified layer. Set it to True to hide the layer or to False to show it. See HideLayer for details.

Type
This style element allows you to change the layer type. Please note that if you change the type of a layer, you will most likely need to provide further information to SetLayerStyle(). For instance, if you choose to convert a #ELLIPSE layer into a #BRUSH layer, it is mandatory that you also specify the ID style element to tell Hollywood which brush shall replace the ellipse layer. Hollywood will try to inherit general style elements like color, position, size from the previous layer type, but for certain type conversions you need to specify additional elements. If Type is specified, only style elements that are supported by the newly set type will be handled. (V4.5)

ClipRegion
Use this style to change the clipping region of this layer. Every layer can have its private clip region. See SetClipRegion for details.

ScaleX, ScaleY
This is an alternative way of scaling the layer. You have to pass a floating point value here that indicates a scaling factor. For example, 0.5 means half the size, 2.0 means twice the size. This is especially convenient if you would like to keep the proportions of the layer that you want to scale. If you use the same factor for ScaleX and ScaleY, the proportions of the layer will remain intact. Please note that ScaleX / ScaleY and Width / Height are mutually exclusive. You must not mix both groups. Either use ScaleX / ScaleY or stick to Width / Height. (V4.5)

Transform
This tag allows you to apply a 2x2 transformation matrix to this layer. Transformation matrices are useful if you want to apply scaling and rotation at the same time, or if you want to mirror a layer. You have to pass a table to Transform. The table must contain the four constituents of a 2x2 transformation matrix in the following order: sx, rx, ry, sy. See TransformBrush for more about transformation matrices. Please note that the Transform tag is mutually exclusive with the following tags: Width / Height / ScaleX / ScaleY / Rotate. You must not combine it with any of these tags. (V4.5)

AnchorX, AnchorY
You can use these two tags to change the anchor point of this layer. The anchor point can be any point between 0.0/ 0.0 (top left corner of the layer) and 1.0/1.0 (bottom right corner of the layer). The center of the layer would be defined by an anchor point of 0.5/0.5. All transformations (scaling, rotation etc.) will be applied relative to the anchor point. Also, the position of a layer is always relative to its anchor point. See SetLayerAnchor for details. (V4.5)

NoClipTransform
This tag can be used to disable automatic clip region transformation. By default, when you transform a layer, its clip region will be transformed in the same vein. To forbid this behaviour, set NoClipTransform to True.

TextureX, TextureY
These tags only work with graphics primitives that are filled using #FILLTEXTURE style. If that is the case, you can use these tags to control the start offset inside the texture brush. See SetFillStyle for details. (V4.6)

Z
This tag can be used to change the z-position of this layer. The z-position of a layer is its position in the hierarchy of layers. The first (i.e. backmost layer) has a z-position of 1, the last (i.e. frontmost) layer's z-position is equal to the number of layers currently present. You need to pass the new desired z-position for the specified layer in this tag. The layer will then assume exactly this z-position, existing layers that are on or after this z-position will be shifted down. To move a layer all the way to the front (i.e. highest z-position), you can pass the special value 0; to move a layer all the way to the back, specify 1. See SetLayerZPos for details. (V4.7)

TranslateX, TranslateY
These two can be used to translate a layer by a specified delta x and delta y offset. A layer translation means moving the layer relative by the specified delta offsets relative to its current position. Thus, a translation of (1,1) would move the layer one pixel to the right, and one pixel to the bottom. See TranslateLayer for details. Please note: These two tags and the X / Y tags are mutually exclusive. You cannot use them together. (V4.7)

Shadow
This tag can be used to turn the drop shadow of a layer on and off. If you set this tag to True, the drop shadow will be turned on, else it will be turned off. If you are turning it on, you can configure the look of the shadow using the ShadowDir, ShadowSize, ShadowColor, and ShadowRadius tags. See below for more information. See SetLayerShadow for details. (V5.0)

ShadowDir
Specifies the direction of the shadow for this layer. This must be one of Hollywood's directional constants. This tag is only handled when the shadow is currently turned on. (V5.0)

ShadowColor
Specifies the color of the shadow for this layer. This must be an ARGB value that can contain a transparency setting. This tag is only handled when the shadow is currently turned on. (V5.0)

ShadowPen
Specifies the pen to use for drawing the layer's shadow when palette is #PALETTEMODE_PEN. See SetShadowPen for details. (V9.0)

ShadowSize
Specifies the size of the shadow for this layer. This tag is only handled when the shadow is currently turned on. (V5.0)

ShadowRadius
Specifies the shadow radius for this layer. This tag is only handled when the shadow is currently turned on. (V5.0)

Border
This tag can be used to turn the border frame of a layer on and off. If you set this tag to True, the border frame will be turned on, else it will be turned off. If you are turning it on, you can configure the look of the border using the BorderSize and BorderColor tags. See below for more information. See SetLayerBorder for details. (V5.0)

BorderColor
Specifies the color of the border for this layer. This must be an ARGB value that can contain a transparency setting. This tag is only handled when the border is currently turned on. (V5.0)

BorderPen
Specifies the pen to use for drawing the layer's border when palette mode is #PALETTEMODE_PEN. See SetBorderPen for details. (V9.0)

BorderSize
Specifies the size of the border for this layer. This tag is only handled when the border is currently turned on. (V5.0)

Filters
This tag can be used to apply filters to a layer, remove filters from a layer, or modify the parameters of already applied filters. You have to pass a table to this tag that describes the desired configuration of the single filters. See SetLayerFilter for details. (V5.0)

ClearFilters
This tag can be used to remove all filters from a layer. Simply specify True here and SetLayerStyle() will remove all filters that are currently active from this layer.

PaletteMode
Specifies the palette mode to use for the layer when Hollywood is in palette mode. This must be one of the palette modes supported by SetPaletteMode(). See SetPaletteMode for details. (V9.0)

DitherMode
Specifies the dither mode to use for the layer when Hollywood is in palette mode. This must be one of the dither modes supported by SetDitherMode(). See SetDitherMode for details. (V9.0)

IgnoreAnchor
If this tag is set to True, Hollywood will ignore the layer's anchor point when changing its position or style. This means that the anchor point will be treated as 0/0. This can be useful e.g. if you'd like to change the text of a layer whose anchor point is not 0/0. In such cases changing the text would also re-position the layer. This can be prevented by setting IgnoreAnchor to True. IgnoreAnchor can also be useful in case you want to position layers, whose anchor point is not 0/0, relative to their top-left corner. (V9.1)

Refresh
Force a layer refresh. This is only useful for merged layers created by MergeLayers() because they don't refresh automatically when the graphics of one or more of its source layers are changed. See MergeLayers for details. (V10.0)

The following style elements are dependent on a specific layer type:

#ANIM layers can use the following elements:

ID
This table element can be used to assign a new animation to the specified layer. The old animation will then be replaced with the animation specified in ID.

Frame
You can use this style element to display a specific frame of the animation that sits on this layer. Frames are counted from 1. You can pass the special value 0 to display the next frame in the animation. See NextFrame for details.

#BRUSH, #BRUSHPART and #BGPICPART layers recognize the following elements:

ID
This table element can be used to assign a new brush/bgpic to the specified layer. The old brush/bgpic will then be replaced with the new one specified by ID. This is useful for example for a slideshow in which a layer shall display a new picture every n seconds.

PartX, PartY, PartWidth, PartHeight
These four elements allow you to configure the visible portion of the brush or bgpic. PartX and PartY specify the x and y coordinates inside the brush/bgpic and PartWidth and PartHeight specifies the size of the tile that shall be visible. This is useful for displaying only a part of a brush or bgpic. For more information please read the notes on DisplayBrushPart() and DisplayBGPicPart(). Please note that these elements are not restricted to layer types #BRUSHPART and #BGPICPART only but they can also be used with layers of type #BRUSH. If you use one of the PartXXX elements on #BRUSH layer, the layer will automatically be changed into a #BRUSHPART layer.

The following elements are generic for layer types #ARC, #BOX, #CIRCLE, #ELLIPSE, #POLYGON, and #VECTORPATH:

Color
Specifies the color of the layer in ARGB notation.

DrawPen:
When palette mode is #PALETTEMODE_PEN, DrawPen specifies the pen that should be used to draw this layer. See SetDrawPen for details. (V9.0)

FormStyle
This allows you to change the form style of the layer. You can pass one or more styles here. If you pass multiple form styles, you need to use the bitwise Or operator (|). See SetFormStyle for possible combinations. If you want to remove a form style from a layer, use the FormStyleClear element. Note: As of Hollywood 5.0 the only reasonable style to set using this tag is #ANTIALIAS because the shadow and border settings are now better controlled using their separate tags (see above).

FormStyleClear
All form styles which you set in this element will be removed from the layer. Multiple form styles have to be separated by the bitwise Or operator (|). This is the counterpart to the FormStyle element. Note: As of Hollywood 5.0 the only reasonable style to unset using this tag is #ANTIALIAS because the shadow and border settings are now better controlled using their separate tags (see above).

FillStyle
You can use this style element to change the filling style for this layer. See SetFillStyle for details.

GradientStyle
Specifies the style of the gradient if filling style is set to #FILLGRADIENT. This can be #LINEAR, #RADIAL, or #CONICAL.

GradientAngle
Specifies the orientation of the gradient if filling style is set to #FILLGRADIENT. The angle is expressed in degrees. Only possible for #LINEAR and #CONICAL gradients.

GradientStartColor, GradientEndColor
Use these two to configure the colors of the gradient if filling style is set to #FILLGRADIENT.

GradientCenterX, GradientCenterX
Sets the center point for gradients of type #RADIAL or #CONICAL. Must be a floating point value between 0.0 and 1.0. See CreateGradientBGPic for details. (V5.0)

GradientBalance
This tag controls the balance point for gradients of type #CONICAL. Must be a floating point value between 0.0 and 1.0. See CreateGradientBGPic for details. (V5.0)

GradientBorder
This tag controls the border size for gradients of type #RADIAL. Must be a floating point value between 0.0 and and 1.0. See CreateGradientBGPic for details. (V5.0)

GradientColors
This tag can be used to create a gradient between more than two colors. This has to be set to a table that contains sequences of alternating color and stop values. See CreateGradientBGPic for details. If this tag is used, the GradientStartColor and GradientEndColor tags are ignored. (V5.0)

OutlineThickness
If filling style is set to #FILLNONE this value can be used to configure the thickness of the outline. See SetFillStyle for details.

TextureBrush
If filling style is set to #FILLTEXTURE you can change the currently used texture with this style element. Simply pass the identifier of a brush in this style element to switch to a new texture.

In addition to the elements above, layers of type #ARC accept the following style elements:

RadiusA, RadiusB
These two values specify the x and y radii of the partial ellipse.

StartAngle, EndAngle
These two values specify the start and end angles of the partial ellipse. See Arc for details.

Clockwise
Specifies whether or not elliptic arc shall be drawn in clockwise direction. See Arc for details. (V4.5)

Layers of type #BOX accept the following additional style elements:

SizeX, SizeY
You can use these two values to change the dimensions of the rectangle. SizeX specifies the rectangle width and SizeY specifies its height.

RoundLevel
Specifies the rounding levels for the four corners of the rectangle. A value of 0 means no rounding. A value of 100 means completely round corners. See Box for details.

CornerA, CornerB, CornerC, CornerD
These four tags allow you to fine-tune the corner rounding of the rectangle. You can specify a rounding level (0 to 100) for every corner of the rectangle thus allowing you to create a rectangle where not all corners are rounded, or where the different corners use different rounding levels. These tags will override any setting specified in the RoundLevel tag. (V5.0)

Layers of type #CIRCLE accept the following additional style elements:

Radius
Specifies the radius of the circle. See Circle for details.

Layers of type #ELLIPSE accept the following additional style elements:

RadiusA, RadiusB
These two values specify the x and y radii of the ellipse. See Ellipse for details.

Layers of type #LINE accept the following additional style elements:

Thickness
Specifies the thickness of the line. See Line for details.

X1,Y1,X2,Y2
Use these tags to change the line orientation. Please note that these tags are mutually exclusive with the generic X / Y tags. If you use those tags, you must not use these tags and vice versa. (V4.6)

Arrowhead
This tag allows you to turn the line into an arrow. It can be set to one of the following tags:

#ARROWHEAD_NONE
No arrowhead. This is the default mode.

#ARROWHEAD_SINGLE
Add arrowhead to end of line.

#ARROWHEAD_DOUBLE
Add arrowhead to start and end of line.

(V9.1)

Layers of type #POLYGON accept the following additional style elements:

Vertices
This style element can be used to change the look of the polygon by passing a new set of vertices to it. You have to set this style element to a table of vertices containing a sequence of x and y coordinates where both coordinates define one vertex. It uses the same format as with the Polygon() command except that you do not have to specify the number of vertices in the table. SetLayerStyle() will determine this automatically.

#PRINT and #TEXTOUT layers recognize the following style elements:

Color
Specifies the color of the text in ARGB notation.

DrawPen:
When palette mode is #PALETTEMODE_PEN, DrawPen specifies the pen that should be used to draw the text. See SetDrawPen for details. (V9.0)

FontStyle
This allows you to change the font style of the layer. You can pass one or more styles here. If you pass multiple font styles, you need to use the bitwise Or operator (|). See SetFontStyle for possible combinations. If you want to remove a font style from a layer, use the FontStyleClear element. Note: As of Hollywood 5.0 this tag should no longer be used to set shadow and border styles. For these styles, you should better use their new separate tags (see above).

FontStyleClear
All font styles which you set in this element will be removed from the layer. Multiple font styles have to be separated by the bitwise Or operator (|). This is the counterpart to the FontStyle element. Note: As of Hollywood 5.0 this tag should no longer be used to unset shadow and border styles. For these styles, you should better use their new separate tags (see above).

Font
You can use this style element to change the font of the text layer. See SetFont for details. Alternatively, you can also specify the new font by setting the ID tag (see below).

FontSize
You can use this style element to change the font size of the specified text layer. See SetFont for details.

ID
You can use this style element to change the font of the text layer. Just set this tag to the ID of the new font and the font will be changed. See UseFont for details. Alternatively, you can also specify the new font by name by setting the Font tag (see above). (V10.0)

Text
This style element allows you to change the contents of the text layer. You can replace the whole old contents of the layer with some new text.

Align
Allows you to change the text alignment after a newline characters. Possible values are #LEFT, #RIGHT, #CENTER, and #JUSTIFIED. The default alignment is #CENTER.

LeftMargin, RightMargin
Allows you to change the margin settings of the current text layer. LeftMargin is only used for layers of type #PRINT but RightMargin can also be used for text objects and #TEXTOUT layers. See SetMargins for details.

CursorX, CursorY
Allows you to change the cursor position of this layer. This is only possible with layers of type #PRINT. Also note that if you specify CursorX / CursorY you must not specify X / Y. CursorX / CursorY and X / Y are mutually exclusive and hence must not be used together. (V4.5)

Tabs
Allows you to modify the tabulator positions for this layer. This is only possible with layers of type #PRINT. Tabs takes a table of tabulator positions. See AddTab for details. (V4.5)

Encoding
Allows you to change the character encoding of this text layer. See SetDefaultEncoding for details. (V4.7)

Linespacing:
Allows you to adjust the space between lines. You can set this to a positive or negative value. A positive value will increase the space between lines, a negative value will decrease it. (V9.0)

Charspacing:
Allows you to adjust the space between characters. You can set this to a positive or negative value. A positive value will increase the space between characters, a negative value will decrease it. (V10.0)

Tabs:
Allows you to modify the tab stops for this layer. See TextOut for details. (V9.0)

ListMode:
Allows you to enable or disable list mode for this text layer. See TextOut for details. (V9.0)

DefListBullet:
Use this tag to set the default bullet to use when the text layer is in list mode. See TextOut for a list of available bullets. (V9.0)

ListBullet:
Use this tag to specify a custom set of bullets to use when the text layer is in list mode. See TextOut for details. (V9.0)

DefListIndent:
This tag can be used to specify the number of spaces to use for indenting list items when the text layer is in list mode. See TextOut for details. (V9.0)

ListIndent:
Use this tag to specify a custom set of indentation levels to use when the text layer is in list mode. See TextOut for details. (V9.0)

DefListOffset:
When the text layer is in list mode and uses a numbered bullet type you can use this tag to specify a starting offset for the numbering. See TextOut for details. (V9.0)

ListOffset:
When the text layer is in list mode and uses a numbered bullet type you can use this tag to specify a custom set of starting offsets for the individual list numbering. See TextOut for details. (V9.0)

DefListSpacing:
This tag can be used to specify the line spacing between the list items when the text layer is in list mode. See TextOut for details. (V9.1)

ListSpacing:
Use this tag to specify a custom set of line spacings to use when the text layer is in list mode. See TextOut for details. (V9.1)

Frame:
When the text layer is in list mode, you can use this tag to display a specific frame of the list. Frames are counted from 1. To show the next frame, you can pass the special value 0 to Frame. See TextOut for details. (V9.0)

FrameMode:
When the text layer is in list mode, you can use this tag configure the frame mode that the list should use. See TextOut for details. (V9.0)

BulletColor:
When the text layer is in list mode, you can use this tag to change the bullet color. See TextOut for details. (V9.0)

BulletPen:
When the text layer is in list mode, you can use this tag to change the bullet pen. See TextOut for details. (V9.0)

Wordwrap:
This tag can be used to set a wordwrapping width for the text layer. Whenever a word exceeds the specified width, it will be wrapped to the next line. Set Wordwrap to 0 to disable wordwrapping. (V9.0)

Layers of type #TEXTOBJECT accept the following additional style elements:

ID
This style element can be used to associate a new text object with this layer. Just pass the identifier of the desired text object here and it will replace the current text object of this layer. (V4.5)

Layers of type #VECTORPATH accept the following additional style elements:

ID
This style element can be used to associate a new vector path object with this layer. Just pass the identifier of the desired vector path object here and it will replace the current path of this layer. (V5.0)

LineJoin
Allows you to change the line join style of this layer. See SetLineJoin for details. (V5.0)

LineCap
Allows you to change the line cap style of this layer. See SetLineCap for details. (V5.0)

FillRule
Allows you to change the fill rule style of this layer. See SetFillRule for details. (V5.0)

Dashes
This style element can be used to change the dash pattern for outline vector drawing. You have to pass a table here that contains a dash pattern in the same format as described in the documentation of the SetDash() command. When passing the Dashes tag, you should also pass the DashOffset tag (see below) to define the starting offset of the dash pattern. (V5.0)

DashOffset
This tag can be used to modify the starting offset of the dash pattern of this layer. This tag is usually specified together with the Dashes tag (see above). See SetDash for details. (V5.0)

VectorEngine:
This tag can be used to set the vectorgraphics renderer that should be used to draw this layer. See SetVectorEngine for details. (V6.0)

#VIDEO layers recognize the following elements:

ID
This tag can only be queried by using GetLayerStyle(). It contains the identifier of the video that has been assigned to this layer. You cannot currently assign a new video object to a layer using SetLayerStyle(). (V6.0)

PartX, PartY, PartWidth, PartHeight
These four elements allow you to configure the visible portion of the video layer. PartX and PartY specify the x and y coordinates inside the video and PartWidth and PartHeight specifies the size of the tile that shall be visible. This is useful for displaying only a part of a video. (V6.0)

Inputs
id1
identifier of the layer or layer group whose style you want to change
style1
table containing one or more style elements from the lists above
...
optional: you can repeat the id/style sequence as often as you need so you can modify the styles of many layers with just a single call
Example
SetLayerStyle(1, {x = #LEFT, y = #TOP}, 4, {x = #CENTER, y = #CENTER},
5, {x = #RIGHT, y = #BOTTOM}, "mylayer", {x = 100, y = 100})
The call above changes the position of several layers. Layer 1 is moved to the top left corner, layer 4 to the center, layer 5 to the bottom right corner, and layer "mylayer" is moved to 100:100.


Box(0, 0, 100, 100, #BLUE)
WaitLeftMouse
SetLayerStyle(1, {Color = #RED})
The code above draws a blue box on the screen, waits for the left mouse button and then changes the color of the box to red.


SetLayerStyle(1, {Frame = 0})
The code above displays the next frame of layer 1 (which must be of type #ANIM).


Polygon(#CENTER, #CENTER, {0, 0, 319, 0, 319, 159, 0, 159}, 4, #RED)
WaitLeftMouse
SetLayerStyle(1, {Vertices = {0, 159, 160, 0, 319, 159}, Color = #YELLOW})
The code above draws a red rectangular polygon, waits for left mouse and then changes the rectangular polygon into a yellow triangular polygon.


Box(0, 0, 100, 100, #RED)
WaitLeftMouse
SetLayerStyle(1, {Type = #BRUSH, ID = 1})
The code above draws a red box on the screen, waits for the left mouse button and then replaces the red rectangle by brush number 1. The layer type is changed from #BOX to #BRUSH.

Show TOC