LittleJS Debug System
- Press Esc to show debug overlay with mouse pick
- Number keys toggle debug functions
- +/- apply time scale
- Debug primitive rendering
- Save a 2d canvas as a png image
- Source
Members
(static, constant) debug :Boolean
True if debug is enabled
- Boolean
- Default Value
- true
- Source
(static) debugKey :String
Key code used to toggle debug mode, Esc by default
- String
- Default Value
- Escape
- Source
(static) debugOverlay :Boolean
True if the debug overlay is active, always false in release builds
- Boolean
- Source
(static, constant) debugPointSize :Number
Size to render debug points by default
- Number
- Default Value
- 0.5
- Source
(static, constant) enableAsserts :Boolean
True if asserts are enaled
- Boolean
- Default Value
- true
- Source
(static) showWatermark :Boolean
True if watermark with FPS should be shown, false in release builds
- Boolean
- Default Value
- true
- Source
Methods
(static) ASSERT(assert, outputopt)
Asserts if the expression is false, does not do anything in release builds
Name | Type | Attributes | Description |
---|---|---|---|
assert | Boolean | ||
output | Object | <optional> |
- Source
(static) debugCircle(pos, radiusopt, coloropt, timeopt, fillopt)
Draw a debug circle in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
radius | Number | <optional> | 0 | |
color | String | <optional> | #fff | |
time | Number | <optional> | 0 | |
fill | Boolean | <optional> | false |
- Source
(static) debugClear()
Clear all debug primitives in the list
- Source
(static) debugLine(posA, posB, coloropt, thicknessopt, timeopt)
Draw a debug line in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
posA | Vector2 | |||
posB | Vector2 | |||
color | String | <optional> | ||
thickness | Number | <optional> | 0.1 | |
time | Number | <optional> |
- Source
(static) debugOverlap(pA, sA, pB, sB, coloropt)
Draw a debug combined axis aligned bounding box in world space
Name | Type | Attributes | Description |
---|---|---|---|
pA | Vector2 | position A | |
sA | Vector2 | size A | |
pB | Vector2 | position B | |
sB | Vector2 | size B | |
color | String | <optional> |
- Source
(static) debugPoint(pos, coloropt, timeopt, angleopt)
Draw a debug point in world space
Name | Type | Attributes | Description |
---|---|---|---|
pos | Vector2 | ||
color | String | <optional> | |
time | Number | <optional> | |
angle | Number | <optional> |
- Source
(static) debugPoly(pos, points, coloropt, timeopt, angleopt, fillopt)
Draw a debug poly in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
points | Array | |||
color | String | <optional> | #fff | |
time | Number | <optional> | 0 | |
angle | Number | <optional> | 0 | |
fill | Boolean | <optional> | false |
- Source
(static) debugRect(pos, sizeopt, coloropt, timeopt, angleopt, fillopt)
Draw a debug rectangle in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
size | Vector2 | <optional> | Vector2() | |
color | String | <optional> | #fff | |
time | Number | <optional> | 0 | |
angle | Number | <optional> | 0 | |
fill | Boolean | <optional> | false |
- Source
(static) debugSaveCanvas(canvas, filenameopt, typeopt)
Save a canvas to disk
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
canvas | HTMLCanvasElement | |||
filename | String | <optional> | screenshot | |
type | String | <optional> | image/png |
- Source
(static) debugSaveDataURL(dataURL, filename)
Save a data url to disk
Name | Type | Description |
---|---|---|
dataURL | String | |
filename | String |
- Source
(static) debugSaveText(text, filenameopt, typeopt)
Save a text file to disk
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text | String | |||
filename | String | <optional> | text | |
type | String | <optional> | text/plain |
- Source
(static) debugShowErrors()
Show error as full page of red text
- Source
(static) debugText(text, pos, sizeopt, coloropt, timeopt, angleopt, fontopt)
Draw a debug axis aligned bounding box in world space
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text | String | |||
pos | Vector2 | |||
size | Number | <optional> | 1 | |
color | String | <optional> | #fff | |
time | Number | <optional> | 0 | |
angle | Number | <optional> | 0 | |
font | String | <optional> | monospace |
- Source
(static) setDebugKey(key)
Set key code used to toggle debug mode, Esc by default
Name | Type | Description |
---|---|---|
key | String |
- Source
(static) setShowWatermark(show)
Set if watermark with FPS should be shown
Name | Type | Description |
---|---|---|
show | Boolean |
- Source