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 enabled
- 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.<Vector2> | |||
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) debugScreenshot()
Trigger debug system to take a screenshot
- 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