Fork me on GitHub
View source

package haxepunk.graphics

class NineSlice


extends Graphic

A NineSlice is an automatically scaling graphic cut into nine segments (upper/middle/lower and left/middle/right.) NineSlice is useful when a graphic has borders that should remain a constan size as the graphic scales (such as a UI button or panel.)

Constructor

View source

new (source : ImageType, leftWidth : Int = 0, rightWidth : Int = 0, topHeight : Int = 0, bottomHeight : Int = 0) : Void

Constructor.


Parameters:
source   

Source image

leftWidth   

Distance from left side of the source image used for 9-slicing the image

rightWidth   

Distance from right side of the source image used for 9-slicing the image

topHeight   

Distance from top side of the source image used for 9-slicing the image

bottomHeight   

Distance from bottom side of the source image used for 9-slicing the image

Variables

drawCenter : Bool

Set this to false to skip the center, drawing only the border segments.

height : Float

scaleBorder : Bool

If false, the borders will always be drawn at their native resolution, regardless of screen scale.

width : Float

Functions

View source

centerOrigin () : Void

Centers the origin of this NineSlice.

View source

render (point : Vector2, camera : Camera) : Void