paintutils
Utilities for drawing more complex graphics, such as pixels, lines and images.
Changes
- New in version 1.45
| 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
- image
stringThe string containing the raw-image data.
Returns
tableThe parsed image data, suitable for use withpaintutils.drawImage.
Usage
Parse an image from a string, and draw it.
local image = paintutils.parseImage([[ e e e e eeee ]]) paintutils.drawImage(image, term.getCursorPos())
Changes
- New in version 1.80pr1
- image
- loadImage(path)Source
Loads an image from a file.
You can create a file suitable for being loaded using the
paintprogram.Parameters
- path
stringThe file to load.
Returns
table| nil The parsed image data, suitable for use withpaintutils.drawImage, ornilif the file does not exist.
Usage
Load an image and draw it.
local image = paintutils.loadImage("data/example.nfp") paintutils.drawImage(image, term.getCursorPos())
- path
- 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
- xPos
numberThe x position to draw at, where 1 is the far left. - yPos
numberThe y position to draw at, where 1 is the very top. - colour?
numberThe color of this pixel. This will be the current background colour if not specified.
- xPos
- 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
- startX
numberThe starting x position of the line. - startY
numberThe starting y position of the line. - endX
numberThe end x position of the line. - endY
numberThe end y position of the line. - colour?
numberThe color of this pixel. This will be the current background colour if not specified.
Usage
paintutils.drawLine(2, 3, 30, 7, colors.red)
- startX
- 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
- startX
numberThe starting x position of the line. - startY
numberThe starting y position of the line. - endX
numberThe end x position of the line. - endY
numberThe end y position of the line. - colour?
numberThe color of this pixel. This will be the current background colour if not specified.
Usage
paintutils.drawBox(2, 3, 30, 7, colors.red)
- startX
- 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
- startX
numberThe starting x position of the line. - startY
numberThe starting y position of the line. - endX
numberThe end x position of the line. - endY
numberThe end y position of the line. - colour?
numberThe color of this pixel. This will be the current background colour if not specified.
Usage
paintutils.drawFilledBox(2, 3, 30, 7, colors.red)
- startX
- drawImage(image, xPos, yPos)Source
Draw an image loaded by
paintutils.parseImageorpaintutils.loadImage.Parameters
- image
tableThe parsed image data. - xPos
numberThe x position to start drawing at. - yPos
numberThe y position to start drawing at.
- image