Constructor
new TileSlice(tileInfo, slicesopt, borderSizeopt, extraSpaceopt)
Create a tile slice style
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
tileInfo | TileInfo | The tile, or the first of the tiles, to draw with | ||
slices | number | <optional> | 9 | 9 for a nine-slice, 3 for a three-slice, 1 for the whole tile |
borderSize | number | <optional> | Drawn thickness of the edges and corners, undefined for the draw's own default | |
extraSpace | number | <optional> | Extra spacing adjustment of the slices, undefined for the draw's own default |
- Source
const panel = new TileSlice(tile(0, 16), 9, .5); // a border of half a world unit
panel.draw(vec2(0, 5), vec2(10, 4));
uiSystem.defaultSlice = new TileSlice(tile(0, 16), 9, 16); // UI sizes are pixels, every widget made after thisMembers
borderSize :number|undefined
- number |
undefined
| Type | Description |
|---|---|
| number | | Drawn thickness of the edges and corners, undefined for the draw's default |
- Source
extraSpace :number|undefined
- number |
undefined
| Type | Description |
|---|---|
| number | | Extra spacing adjustment of the slices, undefined for the draw's default |
- Source
slices
Properties| Type | Description |
|---|---|
| number | 9 for a nine-slice, 3 for a three-slice, 1 for the whole tile |
- Source
tileInfo
Properties| Type | Description |
|---|---|
| TileInfo | The tile, or the first of the tiles, to draw with |
- Source
Methods
draw(pos, size, coloropt, additiveColoropt, angleopt, useWebGLopt, screenSpaceopt, contextopt)
Draw it as a box in world space, or in screen space
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos | Vector2 | Center position | ||
size | Vector2 | Size of the box | ||
color | Color | <optional> | Color to modulate with | |
additiveColor | Color | <optional> | Additive color | |
angle | number | <optional> | 0 | Angle to rotate by |
useWebGL | boolean | <optional> | glEnable | Use WebGL for rendering |
screenSpace | boolean | <optional> | drawScreenSpace | Are pos and size in screen space? |
context | CanvasRenderingContext2D | | <optional> | Canvas context to use |
- Source
drawScreen(pos, size, coloropt, additiveColoropt, angleopt, useWebGLopt, contextopt)
Draw it as a box in screen space, with the 2D context by default, on top of what WebGL drew, like drawTextScreen
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos | Vector2 | Screen space center position | ||
size | Vector2 | Screen space size | ||
color | Color | <optional> | Color to modulate with | |
additiveColor | Color | <optional> | Additive color | |
angle | number | <optional> | 0 | Angle to rotate by |
useWebGL | boolean | <optional> | false | Use WebGL for rendering |
context | CanvasRenderingContext2D | | <optional> | Canvas context to use |
- Source