Module DebugGfx
Provides graphical debugging for ships and stages. These functions let ship and stage programs draw shapes and text to the screen, which is very useful during development. To enable a user program's graphics, click the "Enable Gfx" checkbox in a ship or stage output console.
There is a hard limit of 4096 of each type of graphic. If you try to add more, they will be ignored. Please let me know if this limit seems unreasonable and I'll consider increasing it or making it configurable.
Graphical debugging is only supported in the GUI version of BerryBots on Mac, Linux, and Windows. For now, there is no graphical debugging on the Raspberry Pi.
Functions
drawCircle (x, y, radius, fillColor, outlineThickness, outlineColor, duration) |
Draws a circle. |
drawLine (x, y, angle, length, thickness, fillColor, outlineThickness, outlineColor, duration) |
Draws a line. |
drawRectangle (left, bottom, width, height, rotation, fillColor, outlineThickness, outlineColor, duration) |
Draws a rectangle. |
drawText (text, x, y, size, color, duration) |
Draws some text. |
enabled () |
Whether graphical debugging is enabled. |
Tables
RgbaColor |
Defines a color in RGBA format to be passed to graphical debugging functions. |
Functions
- drawCircle (x, y, radius, fillColor, outlineThickness, outlineColor, duration)
-
Draws a circle.
Parameters
-
x: The x coordinate of the center of the circle.
-
y: The y coordinate of the center of the circle.
-
radius: The radius of the circle
-
fillColor: (optional) The color of the inside of the circle. Default is transparent.
-
outlineThickness: (optional) The thickness of the outline around the circle. Default is 2.
-
outlineColor: (optional) The color of the outline of the circle. Default is white.
-
duration: (optional) The number of ticks, in game time, that the circle will stay on screen. Default is 1.
See also:
- drawLine (x, y, angle, length, thickness, fillColor, outlineThickness, outlineColor, duration)
-
Draws a line.
Parameters
-
x: The x coordinate where the line starts.
-
y: The y coordinate where the line starts.
-
angle: The angle at which the line extends from its starting point, in radians (0 is east, pi / 2 is north)
-
length: The length of the line.
-
thickness: (optional) The thickness of the line. Default is 2.
-
fillColor: (optional) The color of the line. Default is white.
-
outlineThickness: (optional) The thickness of the outline around the line. The area of the line itself is
length
by thickness
- the outline is in addition to that. Default is 0.
-
outlineColor: (optional) The color of the outline of the line. Default is transparent.
-
duration: (optional) The number of ticks, in game time, that the line will stay on screen. Default is 1.
See also:
- drawRectangle (left, bottom, width, height, rotation, fillColor, outlineThickness, outlineColor, duration)
-
Draws a rectangle.
Parameters
-
left: The x coordinate of the left side of the rectangle.
-
bottom: The y coordinate of the bottom side of the rectangle.
-
width: The width of the rectangle.
-
height: The height of the rectangle.
-
rotation: (optional) The angle to rotate the rectangle around its center point, in radians (0 is east, pi / 2 is north). Default is 0.
-
fillColor: (optional) The color of the inside of the rectangle. Default is transparent.
-
outlineThickness: (optional) The thickness of the outline around the rectangle. The area inside the rectangle is
width
by height
- the outline is in addition to that. Default is 2.
-
outlineColor: (optional) The color of the outline of the rectangle. Default is white.
-
duration: (optional) The number of ticks, in game time, that the rectangle will stay on screen. Default is 1.
See also:
- drawText (text, x, y, size, color, duration)
-
Draws some text.
Parameters
-
text: The text to draw on the screen.
-
x: The x coordinate of the left side of the text.
-
y: The y coordinate of the bottom of the text.
-
size: (optional) Size of characters, in pixels. Default is 28.
-
color: (optional) The color of the text. Default is white.
-
duration: (optional) The number of ticks, in game time, that the text will stay on screen. Default is 1.
See also:
- enabled ()
-
Whether graphical debugging is enabled. To enable graphical debugging for a ship or stage, open its output console by clicking its name in the dock, then check the "Enable Gfx" checkbox.
Return value:
true
if graphical debugging is enabled, false
otherwise
Tables
- RgbaColor
- Defines a color in RGBA format to be passed to graphical debugging functions. Values are in the range of 0-255 and all fields are optional. Default values are 0 for
r
, g
, and b
, and 255 (totally opaque) for a
.
Examples: - Red:
{r=255}
- Yellow:
{r=255, g=255}
- Transparent blue:
{b=255, a=150}
- Black:
{ }
- Transparent:
{a=0}
Fields:
-
r: The red color channel.
-
g: The green color channel.
-
b: The blue color channel.
-
a: The alpha (opacity) channel.