Background

From TrillWiki

Jump to: navigation, search

Background code is the core graphical engine used for building windows and controls.

Contents

[edit] XML Tree

Background code is usually found in the following two places in a skin's XML tree.

<trillian>
<component>
<background>...</background>
</component>
<prefs>
<control>
<background>...</background>
</control>
</prefs>
</trillian>

[edit] Background Code

<background name="<name>" transred="" transgreen="" transblue="" thresred="" thresgreen="" thresblue="">
<source name="bitmap name" left="" top="" right="" bottom="" />
<rect>
<left num="" width="0" />
<top num="" height="0" />
<right num="" width="0" />
<bottom num="" height="0" />
</rect>
</background>

Use source and rect tags to define what bitmap to use and how it will be placed.

[edit] Attributes

Attribute Priority Description, Possible Values
name Required
The different background types
The different background types
Which position in the window which this background tag will affect

Upperleft, Upper, Upperright, Left, Right, Lowerleft, Lower, Lowerright.
(See the Skinning tutorial part 3 for how these are used.)

Background code inside a control can use different names also. For instance buttons use the name to indicate what mouse state is indicated (See the reference for the control in question.)

transred Optional defines the red value of the color used to determine transparency.
transgreen Optional defines the green value of the color used to determine transparency.
transblue Optional defines the blue value of the color used to determine transparency.
thresred Optional Defines how far from the defined transred property the red part of a colour can be and still be made transparent - useful for jpgs.
thresgreen Optional Defines how far from the defined transgreen property the green part of a colour can be and still be made transparent - useful for jpgs.
thresblue Optional Defines how far from the defined transblue property the blue part of a colour can be and still be made transparent - useful for jpgs.
transparent Optional* Necessary in controls (i.e. buttons and switchers) to use native GIF transparency. Not necessary for windows backgrounds, color-based transparency (using transred, etc), or for PNG alpha blending

The trans values are only needed if you are defining transparency with a bitmap. Use these with the mainregion tag to build transparent areas in your windows or non-rectangular shapes.


[edit] thresred, thresgreen & thresblue

To further explain the purpose for these values, we need to look closer. Most people use a shade of magenta for the transparent areas of their skins. The RGB value of this colour is 255,0,255. If this image is saved as a PNG file (a lossless compression format), then this colo(u)r will be perfectly stored, and no change will occur. JPG files, on the other hand, use a form of lossy compression, which is prone to altering areas of colour slightly. This means that 1 pixel, which was 255,0,255 in the original image, may become 246,1,254 in the .JPG.

Obviously, this will not match the transred/green/blue values specified. A thresred value of 10 will allow trillian to match any 'red' part of a colour within 10 of the transred value.

e.g: if the transred value is 230, and the thresred is 10, any red value between 220 and 240 will be valid.

For our example of 246,1,254 if we leave the trans values at 255,0,255 but set the thres values to 9,1,1 then this pixel which has changed due to compression will still be made transparent.

Personal tools