Debug

Debug

LittleJS Debug System
- Press ~ to show debug overlay with mouse pick
- Number keys toggle debug functions
- Debug primitive rendering
- Save a 2d canvas as an image

Members

# (static, constant) ASSERT

Asserts if the experssion is false, does not do anything in release builds

# (static, constant) debug

True if debug is enabled
Default Value:
  • 1

# (static, constant) debugPointSize

Size to render debug points by default
Default Value:
  • 0.5

# (static, constant) enableAsserts

True if asserts are enaled
Default Value:
  • 1

# (static) godMode

True if god mode is enabled, handle this however you want

# (static) showWatermark

True if watermark with FPS should be down
Default Value:
  • 1

Methods

# (static) debugAABB(posA, sizeA, posB, sizeB, coloropt)

Draw a debug axis aligned bounding box in world space
Parameters:
Name Type Attributes Default Description
posA Vector2
sizeA Vector2
posB Vector2
sizeB Vector2
color String <optional>
'#fff'

# (static) debugCircle(pos, radiusopt, coloropt, timeopt, fillopt)

Draw a debug circle in world space
Parameters:
Name Type Attributes Default Description
pos Vector2
radius Number <optional>
0
color String <optional>
'#fff'
time Number <optional>
0
fill Boolean <optional>
0

# (static) debugClear()

Clear all debug primitives in the list

# (static) debugLine(posA, posB, coloropt, thicknessopt, timeopt)

Draw a debug line in world space
Parameters:
Name Type Attributes Default Description
posA Vector2
posB Vector2
color String <optional>
'#fff'
thickness Number <optional>
.1
time Number <optional>
0

# (static) debugPoint(pos, coloropt, timeopt, angleopt)

Draw a debug point in world space
Parameters:
Name Type Attributes Default Description
pos Vector2
color String <optional>
'#fff'
time Number <optional>
0
angle Number <optional>
0

# (static) debugRect(pos, sizeopt, coloropt, timeopt, angleopt, fillopt)

Draw a debug rectangle in world space
Parameters:
Name Type Attributes Default Description
pos Vector2
size Vector2 <optional>
new Vector2()
color String <optional>
'#fff'
time Number <optional>
0
angle Number <optional>
0
fill Boolean <optional>
0

# (static) debugSaveCanvas(canvas, filenameopt)

Save a canvas to disk
Parameters:
Name Type Attributes Description
canvas HTMLCanvasElement
filename String <optional>

# (static) debugText(text, pos, sizeopt, coloropt, timeopt, angleopt, fontopt)

Draw a debug axis aligned bounding box in world space
Parameters:
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'