sumary
tico module
tico.getVersion()
- return:
version: string
graphics module
tico.graphics.getSize()
Returns the current window size
- return:
width: numberheight: number
local w, h = tico.graphics.getSize()
tico.graphics.clear(r, g, b, a)
tico.graphics.clear(color)
Clear the current framebuffer
If none argument is passed, clear to black
- args:
r: numberg: numberb: numbera: number (255)
- args:
color: table ({0, 0, 0})
function tico.draw()
tico.graphics.clear(255, 0, 0)
end
Color = require "tico.color"
function tico.draw()
tico.graphics.clear(Color.Red)
end
function tico.draw()
tico.graphics.clear({255, 0, 0})
end
tico.graphics.newCanvas(width, height)
Create a new canvas (OpenGL framebuffer)
- args:
width: numberheight: number
- return:
Canvas: userdata
Canvas functions:
:draw(x, y, angle, scaleX, scaleY, centerX, centerY, color)
:draw(x, y, color)
Draw the canvas
All arguments are optional
- args:
x: number (0)y: number (0)angle: number (0)scaleX: number (1)scaleY: number (1)centerX: number (0)centerY: number (0)color: table ({255, 255, 255})
:auto()
Draw canvas and auto scale to fit window size but maintain the ratio
:getWidth()
Get the canvas texture width
- return:
width: number
:getHeight()
Get the canvas texture height
- return:
height: number
:getSize()
Get the canvas texture size
- return:
width: numberheight: number
:attach()
Attach the Canvas
:detach()
Detach the Canvas, backing to the default framebuffer
function tico.load()
canvas = tico.graphics.newCanvas(320, 240)
end
function tico.draw()
canvas:attach()
tico.graphics.clear()
tico.graphics.drawRectangle(0, 0, 32, 32)
canvas:detach()
canvas:auto()
end
tico.graphics.newImage(filename)
Creates a new image
- args:
filename: string
- return:
Image: userdata
Image functions
:draw(x, y, angle, scaleX, scaleY, centerX, centerY, color)
Draw the image
All arguments are optional
- args:
x: number (0)y: number (0)angle: number (0)scaleX: number (1)scaleY: number (1)centerX: number (0)centerY: number (0)color: table ({255, 255, 255})
:getWidth()
Get the image’s width
- return:
width: number
:getHeight()
Get the image’s height
- return:
height: number
:getSize()
Get the image’s size
- return:
width: numberheight: number
function tico.load()
image = tico.graphics.newImage("image.png")
end
function tico.draw()
image:draw(32, 32)
end
tico.graphics.newRectangle(x, y, w, h)
Creates a new Rectangle
- args:
x: numbery: numberw: numberh: number
- return:
Rectangle: userdata
Rectangle functions
:width()
Get the rectangle width
- return
width: number
:height()
Get the rectangle height
- return
height: number
:x()
Get the rectangle x
- return
x: number
:y()
Get the rectangle y
- return
y: number
tico.graphics.drawRectangle(x, y, w, h, color)
Draw a lined rectangle
- args:
x: numbery: numberw: numberh: numbercolor: table ({255, 255, 255})
tico.graphics.fillRectangle(x, y, w, h, color)
Draw a filled rectangle
- args:
x: numbery: numberw: numberh: numbercolor: table ({255, 255, 255})
tico.graphics.drawCircle(x, y, radius, color)
Draw a lined circle
- args:
x: numbery: numberradius: numbercolor: table ({255, 255, 255})
tico.graphics.fillCircle(x, y, radius, color)
Draw a filled circle
- args:
x: numbery: numberradius: numbercolor: table ({255, 255, 255})
tico.graphics.drawTriangle(x0, y0, x1, y1, x2, y2, color)
Draw a lined triangle
- args:
x0, x1, x2: numbery0, y1, y2: numbercolor: table ({255, 255, 255})
tico.graphics.fillTriangle(x0, y0, x1, y1, x2, y2, color)
Draw a lined triangle
- args:
x0, x1, x2: numbery0, y1, y2: numbercolor: table ({255, 255, 255})
tico.graphics.line(x0, y0, x1, y1, color)
Draw a line
-args:
- x0, x1: number
- y0, y1: number
- color: table ({255, 255, 255})
tico.graphics.scissor(x, y, w, h)
Set a scissor
- args:
x: numbery: numberw: numberh: number
tico.graphics.print(text, x, y, color)
tico.graphics.print(Font, text, x, y, color)
Draw text on the screen
- args:
font: Font (defaultFont)text: stringx: numbery: numbercolor: number
tico.graphics.printf(text, x, y, sx, sy, color)
tico.graphics.printf(Font, text, x, y, sx, sy, color)
extended tico.graphics.print