User Tools

Site Tools


dragengine:modules:dragonscript:xmlguitheme:canvascreator

Start Page » DragonScript Scripting Language » Gui Themes » Define XML Canvas Creator

Canvas Creators

Canvas creators can be defined as parameters using the canvasCreator tag or inside own XML files typically with the extension *.ccreator.xml. The extension can be chosen differently if required. For both versions the same tag definition is used.

Canvas creators are always based directly or indirectly on a type. This type is the Canvas Creator Prototype and defines what instance of CanvasCreator is used in the scripts. The choice of prototype affects the appearance of the canvas creator and the configuration possibilities.

The following prototypes are provided by default by the CanvasCreators script class:

Name Script Class Description
Default DefaultCanvasCreator Empty canvas creator
Rectangle RectangleCanvasCreator Filled or empty rectangle
Bevel BevelCanvasCreator Filled or empty two-color bevelled border
Image ImageCanvasCreator Image stretched across entire canvas
ImageBorder ImageBorderCanvasCreator Up to 9 images creating size adapting border

You can use custom prototypes by adding them to CanvasCreators instance before loading gui themes. This is useful if you created custom canvas creator subclasses requiring custom parameters.

This example defines a canvas creator based on the Image prototype displaying canvasImage.png stretched across entire canvas size.

<canvasCreator parameter='ParameterName' type='Image'>
   <image parameter='image'>canvasImage.png</image>
</canvasCreator>

If you modify an existing canvas creator the type of the original canvas creator is taken over. This example creates a canvas creator by loading it from a file and then replaces the image used.

<canvasCreator parameter='ParameterName' extend='imageCreator.ccreator.xml'>
   <image parameter='image'>anotherCanvasImage.png</image>
</canvasCreator>

Canvas Creator Parameters

Canvas creators are configured by setting parameters. For each supported parameter type an own tag exists. See Defining Parameters for an overview of the supported types. The supported parameters by canvas creator type are listed below.

Default

The most basic canvas creator creating no canvas creator at all (empty canvas creator). Creates an instance of the DefaultCanvasCreator script class. This is useful to set an empty canvas creator. As such it has no parameters at all.

Rectangle

Creates a canvas creator drawing a rectangle with optional fill color. Creates an instance of the RectangleCanvasCreator script class. Both the rectangle and fill color are optional.

These parameters can be used:

Parameter Name Supported parameter type Description
colorFill Color Color to use to fill the rectangle. Set to null or use a color with alpha value of 0 to not fill the rectangle
colorLine Color Color to use to outline the rectangle. Set to null or use a color with alpha value of 0 to not outline the rectangle
thickness Floating Point Thickness in pixels of the rectangle outline. Default is 1px width.

Bevel

Creates a canvas creator drawing a bevelled rectangle with optional fill color. Creates an instance of the BevelCanvasCreator script class. Both the rectangle and fill colors are optional.

These parameters can be used:

Parameter Name Supported parameter type Description
colorHilight Color Color to use for the hilight part of the rectangle outline
colorShadow Color Color to use for the shadow part of the rectangle outline
colorBackground Color Color to use to fill the rectangle. Set to null or use a color with alpha value of 0 to not fill the rectangle
colorMatrix ColorMatrix Color matrix to use for the entire canvas.

Image

Creates a canvas creator stretching an image across the entire canvas size. Creates an instance of the ImageCanvasCreator script class. The image is optional. If not set this is the same as the default canvas creator.

These parameters can be used:

Parameter Name Supported parameter type Description
image Image Image to stretch across the entire canvas size
colorMatrix ColorMatrix Color matrix to use for the canvas.

ImageBorder

Creates a canvas creator using up to 9 images to draw a size adapting border. The set of images composes of a center, side images and corner images. The corner images are placed at their original size in each corner. The side images are stretched along the respective border between the corners. The center is stretched to touch all corners. Creates an instance of the ImageBorderCanvasCreator script class. All images are optional. Make sure the sizes of the images match. For example the top-left corner, top-right corner and top side images should have the same height. Otherwise gaps can result. If the canvas gets too small all images are scaled down to fit. This can be a suboptimal result so try to keep widgets using this canvas creator at a reasonable size.

These parameters can be used:

Parameter Name Supported parameter type Description
center Image Image to use at the center of the border. Stretched to fit the all corners
sideLeft Image Image to use as left side of the border. Stretched top-bottom to fit corners
sideTop Image Image to use as top side of the border. Stretched left-right to fit corners
sideRight Image Image to use as right side of the border. Stretched top-bottom to fit corners
sideBottom Image Image to use as bottom side of the border. Stretched left-right to fit corners
cornerTopLeft Image Image to use as top-left corner of the border. Placed at original size in the corner
cornerTopRight Image Image to use as top-right corner of the border. Placed at original size in the corner
cornerBottomLeft Image Image to use as bottom-left corner of the border. Placed at original size in corner
cornerBottomRight Image Image to use as bottom-right corner of the border. Placed at original size in corner
colorMatrix ColorMatrix Color matrix to use for the canvas.
You could leave a comment if you were logged in.
dragengine/modules/dragonscript/xmlguitheme/canvascreator.txt · Last modified: 2018/02/28 16:09 by dragonlord