paintutils

Utilities for drawing more complex graphics, such as pixels, lines and images.

Changes

parseImage(image)Parses an image from a multi-line string
loadImage(path)Loads an image from a file.
drawPixel(xPos, yPos [, colour])Draws a single pixel to the current term at the specified position.
drawLine(startX, startY, endX, endY [, colour])Draws a straight line from the start to end position.
drawBox(startX, startY, endX, endY [, colour])Draws the outline of a box on the current term from the specified start position to the specified end position.
drawFilledBox(startX, startY, endX, endY [, colour])Draws a filled box on the current term from the specified start position to the specified end position.
drawImage(image, xPos, yPos)Draw an image loaded by paintutils.parseImage or paintutils.loadImage.
parseImage(image)Source

Parses an image from a multi-line string

Parameters

  1. image string The string containing the raw-image data.

Returns

  1. table The parsed image data, suitable for use with paintutils.drawImage.

Changes

  • New in version 1.80pr1
loadImage(path)Source

Loads an image from a file.

You can create a file suitable for being loaded using the paint program.

Parameters

  1. path string The file to load.

Returns

  1. table | nil The parsed image data, suitable for use with paintutils.drawImage, or nil if the file does not exist.

Usage

drawPixel(xPos, yPos [, colour])Source

Draws a single pixel to the current term at the specified position.

Be warned, this may change the position of the cursor and the current background colour. You should not expect either to be preserved.

Parameters

  1. xPos number The x position to draw at, where 1 is the far left.
  2. yPos number The y position to draw at, where 1 is the very top.
  3. colour? number The color of this pixel. This will be the current background colour if not specified.
drawLine(startX, startY, endX, endY [, colour])Source

Draws a straight line from the start to end position.

Be warned, this may change the position of the cursor and the current background colour. You should not expect either to be preserved.

Parameters

  1. startX number The starting x position of the line.
  2. startY number The starting y position of the line.
  3. endX number The end x position of the line.
  4. endY number The end y position of the line.
  5. colour? number The color of this pixel. This will be the current background colour if not specified.

Usage

drawBox(startX, startY, endX, endY [, colour])Source

Draws the outline of a box on the current term from the specified start position to the specified end position.

Be warned, this may change the position of the cursor and the current background colour. You should not expect either to be preserved.

Parameters

  1. startX number The starting x position of the line.
  2. startY number The starting y position of the line.
  3. endX number The end x position of the line.
  4. endY number The end y position of the line.
  5. colour? number The color of this pixel. This will be the current background colour if not specified.

Usage

drawFilledBox(startX, startY, endX, endY [, colour])Source

Draws a filled box on the current term from the specified start position to the specified end position.

Be warned, this may change the position of the cursor and the current background colour. You should not expect either to be preserved.

Parameters

  1. startX number The starting x position of the line.
  2. startY number The starting y position of the line.
  3. endX number The end x position of the line.
  4. endY number The end y position of the line.
  5. colour? number The color of this pixel. This will be the current background colour if not specified.

Usage

drawImage(image, xPos, yPos)Source

Draw an image loaded by paintutils.parseImage or paintutils.loadImage.

Parameters

  1. image table The parsed image data.
  2. xPos number The x position to start drawing at.
  3. yPos number The y position to start drawing at.