All pages
Powered by GitBook
1 of 6

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Blend

Introduction

The Blend variable controls how the selected instance combines its colors with whatever is drawn before. The final appearance of a NineSlice depends on its Blend, Alpha, Source File, and Color values.

For more information and examples, see the Sprite Blend page.

NineSlice

Introduction

NineSlice is a standard component which can be used to create visual objects which can stretch to any size without creating distortion on the source image. For example, consider the following image:

This image could be used to create nine slices of various sizes without any distortion:

The NineSlice achieves this effect by splitting the texture into nine pieces, and scales each one differently to prevent distortion. Highlighting a nine slice shows how it is split:

This is achieved by splitting the texture into 1/3 sections wide and tall. The following image shows how the original image will be split:

NineSlice Texture

The simplest way to assign a texture to a NineSlice is to use a single file. Setting the SourceFile to a single PNG will result in the NineSlice using that one texture, where each section of the NineSlice displays 1/3 of the width of the file and 1/3 of the height of the file.

A NineSlice's Texture Address property can be used to change the portion of the source texture that it uses. More info can be found in the Texture Address subpage.

Alternatively, nine files can be used to specify each section of the NineSlice independently. To use nine individual files, each file must be given a specific suffix.

The following suffixes can be added to create nine slice graphics. For example, assuming your NineSlice image is called "Image" and you are using the .png file format:

  • Image_BottomCenter.png

  • Image_BottomLeft.png

  • Image_BottomRight.png

  • Image_Center.png

Image_Left.png

  • Image_Right.png

  • Image_TopCenter.png

  • Image_TopLeft.png

  • Image_TopRight.png

  • Custom Frame Texture Coordinate Width

    Introduction

    The Custom Frame Texture Coordinate Width property allows a NineSlice to customize the number of pixels used on the source texture when defining its outer frame. This allows for fine control over which parts of a NineSlice stretch and which parts are used as the corners and edges.

    By default this value is null, which means the NineSlice automatically dedicates 1/3 of the texture for the edges.

    Changing Custom Frame Texture Coordinate Width

    If the Custom Frame Texture Coordinate Width value is changed, then the source texture applies a fixed pixel size to the borders. For example, using the image above, the frame can be changed to 3 so that only the black and white pixels are part of the border.

    NineSlice with an explicitly-set 3 pixel border width

    Texture Top

    Introduction

    The Texture Top variable controls the top pixel of the source rectangle used to draw the NineSlice. Texture Top is only available if the NineSlice uses a Texture Address of Custom or Dimension Based.

    The following image shows a NineSlice with a Texture Top value of 48.

    Texture Top controls the top side of the region that the NineSlice displays on its source file. In this case, the top-edge of the source rectangle is 48 pixels from the top edge of the entire file.

    NineSlice with Texture Top set to 48
    Texture Top set to 48 pixels in the Texture Coordinates tab

    Texture Address

    Introduction

    The Texture Address variable can be used to define the area that the NineSlice displays. By default the Texture Address is set to Entire Texture which means the NineSlice will display the entire source file (split up among the nine pieces).

    NineSlice only supports Entire Texture and Custom for the Texture Address value. It does not support Dimension Based, which is only available on the element.

    Entire Texture

    The following screenshot shows an entire texture being used for a NineSlice.

    The entire texture is split up into 3 sections horizontally and 3 sections vertically, matching up the texture coordinates used to display the NineSlice's 9 sections.

    Custom

    The Custom value allows specifying a custom set of coordinates for the Nine Slice. Custom is most often used when an image is part of a sprite sheet. The following example uses this image:

    The NineSlice uses the following variables:

    • Texture Address = Custom

    • Texture Top = 0

    • Texture Left = 0

    • Texture Height = 40

    These values result in the the following NineSlice:

    Texture Width = 40

    Sprite

    Texture Left

    Introduction

    The Texture Left variable controls the left pixel of the source rectangle used to draw the NineSlice. Texture Left is only available if the NineSlice uses a Texture Address of Custom or Dimension Based.

    The following image shows a NineSlice with a Texture Left value of 96.

    Texture Left controls the left side of the region that the NineSlice displays on its source file. In this case, the left-edge of the source rectangle is 96 pixels from the left edge of the entire file.

    NineSlice with Texture Left set to 96
    Texture Left set to 96 pixels in the Texture Coordinates tab