Posted 22 November 2012 - 03:27 PM
Hello all.
This API provides developers with functions to draw things on the screen.
Functions:
Graphics API on Pastebin
Graphics API Demo on Pastebin
or, alternatively:
For the API itself:
and for the demo:
This API provides developers with functions to draw things on the screen.
Functions:
- drawPoint(x,y,color) - Sets one pixel/character on the screen
- drawLine(start, end, color) - Draws a line from the first pair of coordinates to the second pair of coordinates
- drawRect(corner1, corner2, color, fill) - Draws a rectangle. Can be filled if needed.
- drawCircle(midpoint, radius, color) - Draws a circle.
- floodFill(startPoint, color) - Fills an area with a color.
- writeText(text, start, color) - writes text starting from (start[1], start[2])
- update() - Draws the contents of the internal buffer to screen.
- resetSurface() - Resets the internal buffer.
- resetScreen() - Clears the screen and changes the colors back to default.
- Points are taken as tables. Example:
myPoint = {5,9}
- The color argument can actually be two things: a number (such as colors.red), or a table.
- When a color argument is a number, it is assumed to be a constant from the colors API.
- However, if it is a table, then it assumes that you're trying to write text to the screen.
- When passing tables to the drawing functions, please ensure that the tables are in this format:
{textColor, character}
- You need to call update after drawing everything to screen, or else you won't see anything happen.
- resetScreen is defined as such:
function resetScreen() term.setTextColor(colors.white) term.setBackgroundColor(colors.black) term.clear() term.setCursorPos(1,1) end
- Surfaces are meant to be used internally;
is equivalent todrawPoint(1,1,colors.red)
, anddrawSurfaces[1][1][1] = colors.red
is equivalent todrawPoint(1,1,{colors.red, "-"})
.drawSurfaces[2][1][1] = {colors.red, "-"}
Graphics API on Pastebin
Graphics API Demo on Pastebin
or, alternatively:
For the API itself:
pastebin get vanFtbrA GraphicsAPI
and for the demo:
pastebin get b6KNBv7D demo