Module system.graphics

The graphics module provides functions to draw primitive geometry on a locked terminal object. It supports both text and graphics mode terminals. The state of text terminals is preserved, so using these functions doesn’t change the cursor position or colors.

Index

Function

drawBox()

Draws an outlined rectangle on screen.

drawCircle()

Draws an outlined circle (or arc) on screen.

drawFilledBox()

Draws a filled rectangle on screen.

drawFilledTriangle()

Draws a filled triangle on screen.

drawImage()

Draws an image on screen.

drawLine()

Draws a line between two points.

drawPixel()

Draws a single pixel on screen.

API Reference

system.graphics.drawPixel(
    term: system.terminal.GFXTerminal | system.terminal.Terminal,
    x: number,
    y: number,
    color: number
)

Draws a single pixel on screen.

Parameters:
system.graphics.drawLine(
    term: system.terminal.GFXTerminal | system.terminal.Terminal,
    x1: number,
    y1: number,
    x2: number,
    y2: number,
    color: number
)

Draws a line between two points.

Parameters:
  • term (system.terminal.GFXTerminal | system.terminal.Terminal) – The terminal to draw on

  • x1 (number) – The start X coordinate to draw at

  • y1 (number) – The start Y coordinate to draw at

  • x2 (number) – The end X coordinate to draw at

  • y2 (number) – The end Y coordinate to draw at

  • color (number) – The color to draw with

system.graphics.drawBox(
    term: system.terminal.GFXTerminal | system.terminal.Terminal,
    x: number,
    y: number,
    width: number,
    height: number,
    color: number
)

Draws an outlined rectangle on screen.

Parameters:
  • term (system.terminal.GFXTerminal | system.terminal.Terminal) – The terminal to draw on

  • x (number) – The upper-left X coordinate to draw at

  • y (number) – The upper-left Y coordinate to draw at

  • width (number) – The width of the rectangle

  • height (number) – The height of the rectangle

  • color (number) – The color to draw with

system.graphics.drawFilledBox(
    term: system.terminal.GFXTerminal | system.terminal.Terminal,
    x: number,
    y: number,
    width: number,
    height: number,
    color: number
)

Draws a filled rectangle on screen.

Parameters:
  • term (system.terminal.GFXTerminal | system.terminal.Terminal) – The terminal to draw on

  • x (number) – The upper-left X coordinate to draw at

  • y (number) – The upper-left Y coordinate to draw at

  • width (number) – The width of the rectangle

  • height (number) – The height of the rectangle

  • color (number) – The color to draw with

system.graphics.drawCircle(
    term: system.terminal.GFXTerminal | system.terminal.Terminal,
    x: number,
    y: number,
    width: number,
    height: number,
    color: number,
    startAngle?: number,
    arcCircumference?: number
)

Draws an outlined circle (or arc) on screen.

Parameters:
  • term (system.terminal.GFXTerminal | system.terminal.Terminal) – The terminal to draw on

  • x (number) – The upper-left X coordinate to draw at

  • y (number) – The upper-left Y coordinate to draw at

  • width (number) – The width of the circle

  • height (number) – The height of the circle

  • color (number) – The color to draw with

  • startAngle? (number) – The angle to start from in radians (starting at the right side) (defaults to 0)

  • arcCircumference? (number) – The amount of the arc to draw in radians (defaults to 2*math.pi)

system.graphics.drawFilledTriangle(
    term: system.terminal.GFXTerminal | system.terminal.Terminal,
    x1: number,
    y1: number,
    x2: number,
    y2: number,
    x3: number,
    y3: number,
    color: number
)

Draws a filled triangle on screen.

Parameters:
  • term (system.terminal.GFXTerminal | system.terminal.Terminal) – The terminal to draw on

  • x1 (number) – The first X coordinate to draw at

  • y1 (number) – The first Y coordinate to draw at

  • x2 (number) – The second X coordinate to draw at

  • y2 (number) – The second Y coordinate to draw at

  • x3 (number) – The third X coordinate to draw at

  • y3 (number) – The third Y coordinate to draw at

  • color (number) – The color to draw with

system.graphics.drawImage(
    term: system.terminal.GFXTerminal | system.terminal.Terminal,
    x: number,
    y: number,
    image: table
)

Draws an image on screen.

The image may be either a valid graphics mode pixel region (using either string or table rows), or a blit table with {text, text color, background color} table rows (text mode only).

Parameters: