[DEVELOPER] GPU API Documentation - Game-Fusion/Commander-64 GitHub Wiki

The GPU API is a flexible, complete API for all of your graphics needs. This is complete documentation of all GPU commands, what they do and how to use them.

Basic clearing and colour setting functions


gpu.blit(text, textcol, backcol)

gpu.blit() functions in nearly the same manner as term.write(), but instead of using the current text and background colours, it accepts additional strings specifying colour codes for each individual character. Although it is no faster than term.write() in its own right, in some circumstances it can reduce code length and speed execution by removing the need to make multiple term.setTextColor() / term.setBackgroundColor() calls.

eg: gpu.blit("a","b","c")

Writes the letter "a", using a blue text colour ("b"), and a brown background colour ("c")


gpu.clr()

Wipes the screen with the current background colour.

eg: gpu.clr()


gpu.center(y, string)

Prints text in the middle of the line requested by "y"

eg: center(1, "Hello world")


gpu.slowWrite(text, speed)

Writes text character-by-character at the specified speed.

eg: gpu.slowWrite("Hello world", 12)


gpu.slowPrint(text, speed)

Prints text character by character at the specified speed.

eg: gpu.slowPrint("Hello world", 13)


gpu.cursPos(x, y)

Sets the position of the cursor.

eg: gpu.cursPos(1,1)


gpu.cursBlink(bool)

Set cursor blink to true or false (bool = boolean).

eg: gpu.cursBlink(true)

Sets cursor blink to true


gpu.centerSlow(y, string)

Same as center, except using slow print.

eg: gpu.centerSlow(1, "Hello world")


gpu.setBg(col)

Sets the background colour

eg: gpu.setBg("black")


gpu.setTxt(col)

Sets the text colour

eg: gpu.setTxt("white")


gpu.clearBg(back)

Sets the specified background colour (back) and clears the screen with it.

eg: gpu.clearBg("red")


gpu.clrLine(y)

Clears the horizontal line specified.

eg: gpu.clrLine(10)

Paintutils derived functions


gpu.loadImg(path)

Loads an image from the path specified into memory.

eg: gpu.loadImg("/pasta")


gpu.drawImg(img, x, y)

Draws an image ("img" is a variable) stored in memory at the specified coordinates.

eg: gpu.drawImg(image, 5, 3)


gpu.drawPixel(x, y, colour)

Draws a pixel at specified coordinates in the given colour.

eg: gpu.drawPixel(36, 15, "blue")


gpu.drawLine(x1, y1, x2, y2, colour)

Draws a line from X1/Y1 to X2/Y2, in the specified colour.

eg: gpu.drawLine(1, 1, 49, 1, "green")


gpu.drawBox(x1, y1, x2, y2, colour)

Draws an unfilled box from X1/Y1 to X2/Y2 in the specified colour.

eg: gpu.drawBox(5, 5, 10, 10, "brown")


gpu.drawFilledBox(x1, y1, x2, y2, colour)

Draws a filled box from X1/Y1 to X2/Y2 in the specified colour.

eg: gpu.drawFilledBox(2, 2, 12, 12, "yellow")