Module ctr.gfx

The gfx module.

Usage:

    local gfx = require("ctr.gfx")

Functions

start (screen[, eye=gfx.LEFT]) Start drawing to a screen/target.
stop () End drawing to a screen.
render () Display any drawn pixel.
getFPS () Get the current number of frame per second.
set3D (enable) Enable or disable the stereoscopic 3D on the top screen.
get3D () Check whether or not the stereoscopic 3D is enabled.
setVBlankWait (true) Enable or disable the VBlank waiting.
waitForVBlank ([screen=GFX_TOP]) Wait for the VBlank interruption.
vramSpaceFree () Get free VRAM space.
point (x, y[, color=default color]) Draw a point, a single pixel, on the current screen.
line (x1, y1, x2, y2[, width=1[, color=default color]]) Draw a line on the current screen.
triangle (x1, y1, x2, y2, x3, y3[, color=default color]) Draw a filled triangle on the current screen.
linedTriangle (x1, y1, x2, y2, x3, y3[, lineWidth=1[, color=default color]]) Draw a triangle outline on the current screen.
rectangle (x, y, width, height[, angle=0[, color=default color[, color2[, direction]]]]) Draw a filled rectangle on the current screen.
linedRectangle (x, y, width, height[, lineWidth=1[, angle=0[, color=default color]]]) Draw a rectangle outline on the current screen.
circle (x, y, radius[, color=default color]) Draw a filled circle on the current screen.
linedCircle (x, y, radius[, width=1[, color=default color]]) Draw a circle outline on the current screen.
text (x, y, text[, size=default size[, color=default color[, font=default font]]]) Draw a text on the current screen.
wrappedText (x, y, text, width[, size=default Size[, color=default color[, font=default font]]]) Draw a text with a new line after a certain number of pixels.
calcBoundingBox (text, lineWidth[, size=default size[, font=default font]]) Calculate the size of a text draw with wrappedText.
scissor (x, y, width, height[, invert=false]) Enables or disable the scissor test.
target (width, height) __Work in progress__.

Tables

color The ctr.gfx.color module.
font The ctr.gfx.font module.
texture The ctr.gfx.texture module.
map The ctr.gfx.map module.

Render targets

:clear ([color=default color]) Clear a target to a specified color.
:destroy () Destroy a target.

Console

console ([screen=gfx.TOP[, debug=false]]) Initialize the console.
clearConsole () Clear the console.
disableConsole () Disable the console.

Constants

TOP Constant used to select the top screen.
BOTTOM Constant used to select the bottom screen.
LEFT Constant used to select the left eye.
RIGHT Constant used to select the right eye.
TOP_HEIGHT The top screen height, in pixels.
TOP_WIDTH The top screen width, in pixels.
BOTTOM_HEIGHT The bottom screen height, in pixels.
BOTTOM_WIDTH The bottom screen width, in pixels.
TOP_TO_BOTTOM Represents a vertical gradient drawn from the top (first color) to the bottom (second color).
LEFT_TO_RIGHT Represents a horizontal gradient drawn from the left (first color) to the right (second color).


Functions

start (screen[, eye=gfx.LEFT])
Start drawing to a screen/target. Must be called before any draw operation.

Parameters:

stop ()
End drawing to a screen. Must be called after your draw operations.
render ()
Display any drawn pixel.
getFPS ()
Get the current number of frame per second.

Returns:

    number number of frame per seconds
set3D (enable)
Enable or disable the stereoscopic 3D on the top screen.

Parameters:

  • enable boolean true to enable, false to disable
get3D ()
Check whether or not the stereoscopic 3D is enabled.

Returns:

    boolean true if enabled, false if disabled
setVBlankWait (true)
Enable or disable the VBlank waiting.

Parameters:

  • true boolean to enable, false to disable
waitForVBlank ([screen=GFX_TOP])
Wait for the VBlank interruption.

Parameters:

  • screen number the screen's VBlank to wait for (default GFX_TOP)
vramSpaceFree ()
Get free VRAM space.

Returns:

    integer free VRAM in bytes
point (x, y[, color=default color])
Draw a point, a single pixel, on the current screen.

Parameters:

  • x integer point horizontal coordinate, in pixels
  • y integer point vertical coordinate, in pixels
  • color integer drawing color (default default color)
line (x1, y1, x2, y2[, width=1[, color=default color]])
Draw a line on the current screen.

Parameters:

  • x1 integer line's starting point horizontal coordinate, in pixels
  • y1 integer line's starting point vertical coordinate, in pixels
  • x2 integer line's endpoint horizontal coordinate, in pixels
  • y2 integer line's endpoint vertical coordinate, in pixels
  • width number line's thickness, in pixels (default 1)
  • color integer drawing color (default default color)
triangle (x1, y1, x2, y2, x3, y3[, color=default color])
Draw a filled triangle on the current screen.

Parameters:

  • x1 integer horizontal coordinate of a vertex of the triangle, in pixels
  • y1 integer vertical coordinate of a vertex of the triangle, in pixels
  • x2 integer horizontal coordinate of a vertex of the triangle, in pixels
  • y2 integer vertical coordinate of a vertex of the triangle, in pixels
  • x3 integer horizontal coordinate of a vertex of the triangle, in pixels
  • y3 integer vertical coordinate of a vertex of the triangle, in pixels
  • color integer drawing color (default default color)
linedTriangle (x1, y1, x2, y2, x3, y3[, lineWidth=1[, color=default color]])
Draw a triangle outline on the current screen.

Parameters:

  • x1 integer horizontal coordinate of a vertex of the triangle, in pixels
  • y1 integer vertical coordinate of a vertex of the triangle, in pixels
  • x2 integer horizontal coordinate of a vertex of the triangle, in pixels
  • y2 integer vertical coordinate of a vertex of the triangle, in pixels
  • x3 integer horizontal coordinate of a vertex of the triangle, in pixels
  • y3 integer vertical coordinate of a vertex of the triangle, in pixels
  • lineWidth number line's thickness, in pixels (default 1)
  • color integer drawing color (default default color)
rectangle (x, y, width, height[, angle=0[, color=default color[, color2[, direction]]]])
Draw a filled rectangle on the current screen.

Parameters:

  • x integer rectangle origin horizontal coordinate, in pixels
  • y integer rectangle origin vertical coordinate, in pixels
  • width integer rectangle width, in pixels
  • height integer rectangle height, in pixels
  • angle number rectangle rotation, in radians (default 0)
  • color integer drawing color (default default color)
  • color2 integer Second drawing color ; if the argument is not nil, the rectangle will be filled with a gradient from color to color2 (optional)
  • direction integer Gradient drawing direction (gfx.TOP_TO_BOTTOM or gfx.LEFT_TO_RIGHT). This argument is mandatory if a second color was specified. (optional)
linedRectangle (x, y, width, height[, lineWidth=1[, angle=0[, color=default color]]])
Draw a rectangle outline on the current screen.

Parameters:

  • x integer rectangle origin horizontal coordinate, in pixels
  • y integer rectangle origin vertical coordinate, in pixels
  • width integer rectangle width, in pixels
  • height integer rectangle height, in pixels
  • lineWidth integer line's thickness, in pixels (default 1)
  • angle number rectangle rotation, in radians (default 0)
  • color integer drawing color (default default color)
circle (x, y, radius[, color=default color])
Draw a filled circle on the current screen.

Parameters:

  • x integer circle center horizontal coordinate, in pixels
  • y integer circle center vertical coordinate, in pixels
  • radius integer circle radius, in pixels
  • color integer drawing color (default default color)
linedCircle (x, y, radius[, width=1[, color=default color]])
Draw a circle outline on the current screen.

Parameters:

  • x integer circle center horizontal coordinate, in pixels
  • y integer circle center vertical coordinate, in pixels
  • radius integer circle radius, in pixels
  • width integer line's thickness, in pixels (default 1)
  • color integer drawing color (default default color)
text (x, y, text[, size=default size[, color=default color[, font=default font]]])
Draw a text on the current screen.

Parameters:

  • x integer text drawing origin horizontal coordinate, in pixels
  • y integer text drawing origin vertical coordinate, in pixels
  • text string the text to draw
  • size integer drawing size, in pixels (default default size)
  • color integer drawing color (default default color)
  • font font to use (default default font)
wrappedText (x, y, text, width[, size=default Size[, color=default color[, font=default font]]])
Draw a text with a new line after a certain number of pixels. Warning: No UTF32 support.

Parameters:

  • x integer text drawing origin horizontal coordinate, in pixels
  • y integer text drawing origin vertical coordinate, in pixels
  • text string the text to draw
  • width integer width of a line, in pixels
  • size integer drawing size, in pixels (default default Size)
  • color integer drawing color (default default color)
  • font font to use (default default font)
calcBoundingBox (text, lineWidth[, size=default size[, font=default font]])
Calculate the size of a text draw with wrappedText.

Parameters:

  • text string The text to check
  • lineWidth integer width of a line, in pixels
  • size integer drawing size, in pixels (default default size)
  • font font to use (default default font)

Returns:

  1. integer width of the text, in pixels
  2. integer height of the text, in pixels
scissor (x, y, width, height[, invert=false])
Enables or disable the scissor test. When the scissor test is enabled, the drawing area will be limited to a specific rectangle, every pixel drawn outside will be discarded. Calls this function without argument to disable the scissor test.

Parameters:

  • x integer scissor rectangle origin horizontal coordinate, in pixels
  • y integer scissor rectangle origin vertical coordinate, in pixels
  • width integer scissor rectangle width, in pixels
  • height integer scissor rectangle height, in pixels
  • invert boolean if true the scissor will be inverted (will draw only outside of the rectangle) (default false)
target (width, height)
__Work in progress__. Create a render target. Don't use it.

Parameters:

  • width integer
  • height integer

Returns:

    target

Tables

color
The ctr.gfx.color module.

See also:

font
The ctr.gfx.font module.

See also:

texture
The ctr.gfx.texture module.

See also:

map
The ctr.gfx.map module.

See also:

Render targets

:clear ([color=default color])
Clear a target to a specified color.

Parameters:

  • color integer color to fill the target with (default default color)
:destroy ()
Destroy a target.

Console

console ([screen=gfx.TOP[, debug=false]])
Initialize the console. You can print on it using print(), or any function that normally outputs to stdout. Warning: you can't use a screen for both a console and drawing, you have to disable the console first.

Parameters:

  • screen number screen to draw the console on. (default gfx.TOP)
  • debug boolean enable stderr output on the console (default false)
clearConsole ()
Clear the console.
disableConsole ()
Disable the console.

Constants

TOP
Constant used to select the top screen. It is equal to 0.
  • TOP
BOTTOM
Constant used to select the bottom screen. It is equal to 1.
  • BOTTOM
LEFT
Constant used to select the left eye. It is equal to 0.
  • LEFT
RIGHT
Constant used to select the right eye. It is equal to 1.
  • RIGHT
TOP_HEIGHT
The top screen height, in pixels. It is equal to 240.
  • TOP_HEIGHT
TOP_WIDTH
The top screen width, in pixels. It is equal to 400.
  • TOP_WIDTH
BOTTOM_HEIGHT
The bottom screen height, in pixels. It is equal to 240.
  • BOTTOM_HEIGHT
BOTTOM_WIDTH
The bottom screen width, in pixels. It is equal to 320.
  • BOTTOM_WIDTH
TOP_TO_BOTTOM
Represents a vertical gradient drawn from the top (first color) to the bottom (second color).
  • TOP_TO_BOTTOM
LEFT_TO_RIGHT
Represents a horizontal gradient drawn from the left (first color) to the right (second color).
  • LEFT_TO_RIGHT
generated by LDoc 1.4.3 Last updated 2017-06-05 14:35:27