DrawUtilities

LittleJS Drawing Utilities Plugin

  • Extra drawing functions for LittleJS
  • Nine slice and three slice drawing

Methods

(static) drawNineSlice(pos, size, startTile, coloropt, borderSizeopt, additiveColoropt, extraSpaceopt, angleopt, useWebGLopt, screenSpaceopt, contextopt)

Draw a scalable nine-slice UI element in world space This function can apply color and additive color if WebGL is enabled

Parameters:
NameTypeAttributesDefaultDescription
posVector2

World space position

sizeVector2

World space size

startTileTileInfo

Starting tile for the nine-slice pattern

colorColor<optional>

Color to modulate with

borderSizenumber<optional>
1

Width of the border sections

additiveColorColor<optional>

Additive color

extraSpacenumber<optional>
0.05

Extra spacing adjustment

anglenumber<optional>
0

Angle to rotate by

useWebGLboolean<optional>
glEnable

Use WebGL for rendering

screenSpaceboolean<optional>

Use screen space coordinates

contextCanvasRenderingContext2D<optional>

Canvas context to use

(static) drawNineSliceScreen(pos, size, startTile, borderSizeopt, extraSpaceopt, angleopt)

Draw a scalable nine-slice UI element to the overlay canvas in screen space This function can not apply color because it draws using the overlay 2d context

Parameters:
NameTypeAttributesDefaultDescription
posVector2

Screen space position

sizeVector2

Screen space size

startTileTileInfo

Starting tile for the nine-slice pattern

borderSizenumber<optional>
32

Width of the border sections

extraSpacenumber<optional>
2

Extra spacing adjustment

anglenumber<optional>
0

Angle to rotate by

(static) drawThreeSlice(pos, size, startTile, coloropt, borderSizeopt, additiveColoropt, extraSpaceopt, angleopt, useWebGLopt, screenSpaceopt, contextopt)

Draw a scalable three-slice UI element in world space This function can apply color and additive color if WebGL is enabled

Parameters:
NameTypeAttributesDefaultDescription
posVector2

World space position

sizeVector2

World space size

startTileTileInfo

Starting tile for the three-slice pattern

colorColor<optional>

Color to modulate with

borderSizenumber<optional>
1

Width of the border sections

additiveColorColor<optional>

Additive color

extraSpacenumber<optional>
0.05

Extra spacing adjustment

anglenumber<optional>
0

Angle to rotate by

useWebGLboolean<optional>
glEnable

Use WebGL for rendering

screenSpaceboolean<optional>

Use screen space coordinates

contextCanvasRenderingContext2D<optional>

Canvas context to use

(static) drawThreeSliceScreen(pos, size, startTile, borderSizeopt, extraSpaceopt, angleopt)

Draw a scalable three-slice UI element to the overlay canvas in screen space This function can not apply color because it draws using the overlay 2d context

Parameters:
NameTypeAttributesDefaultDescription
posVector2

Screen space position

sizeVector2

Screen space size

startTileTileInfo

Starting tile for the three-slice pattern

borderSizenumber<optional>
32

Width of the border sections

extraSpacenumber<optional>
2

Extra spacing adjustment

anglenumber<optional>
0

Angle to rotate by