NineSlice
The NineSlice
class is used for drawing nine-slice images on a canvas.
Constructor
prototype
constructor(area: Rectangle, leftLimit: number, rightLimit: number, topLimit: number, bottomLimit: number, imageName: string, mode: NineSliceMode = NineSliceMode.Stretch, scale: Point = new Point(1, 1))
Properties
area
- Type:
Rectangle
- The area to draw the nine-slice image.
- Type:
leftLimit
- Type:
number
- The left limit of the nine-slice image.
- Type:
rightLimit
- Type:
number
- The right limit of the nine-slice image.
- Type:
topLimit
- Type:
number
- The top limit of the nine-slice image.
- Type:
bottomLimit
- Type:
number
- The bottom limit of the nine-slice image.
- Type:
imageName
- Type:
string
- The name of the image to draw.
- Type:
mode
- Type:
NineSliceMode
- Default value:
NineSliceMode.Stretch
- The mode to draw the nine-slice image.
- Type:
scale
- Type:
Point
- Default value:
ew Point(1, 1)
- The scale of the nine-slice image.
- Type:
Examples
const nineSlice = new NineSlice(
new Rectangle(new Point(0, 0), new Point(100, 100)),
10,
10,
10,
10,
'myImage',
NineSliceMode.Stretch,
new Point(1, 1)
);
const nineSlice = new NineSlice(
new Rectangle(new Point(0, 0), new Point(100, 100)),
10,
10,
10,
10,
'myImage',
);
Getters & Setters
area
- Type:
rectangle
The area to draw the nine-slice image.
Methods
draw
prototype
draw(context: CanvasRenderingContext2D): void;
Draws the nine slice.
Parameters
context
- Type:
CanvasRenderingContext2D
- The canvas rendering context.
- Type:
Return
void
Example
nineSlice.draw(context);