No description
- Go 73.9%
- Lua 26.1%
| cli | ||
| draw | ||
| drawWrapper | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| README.md | ||
| script.lua | ||
luaDraw
Simple drawing programm using gopher-lua and fenster.
Usage
The default file generated with
./luaDraw gd
--[[
lua function list:
* draw:Println(text) - prints text to console
* draw:Rect(x, y, w, h, color) - draws rectangle outline
* draw:FillRect(x, y, w, h, color) - draws filled rectangle
* draw:Line(x1, y1, x2, y2, color) - draws line
* draw:Circle(x, y, radius, color) - draws circle outline
* draw:ClearScreen() - manually clears screen (not needed with autoclear)
* draw:KeyDown(key) - check if a key is pressed (follows https://www.toptal.com/developers/keycode)
lua variable list:
* Interval int - determines drawing fps (default: 30)
* AutoClearScreen bool - sets auto clearing of screen (default: true)
color list:
* green
* red
* blue
* black
* white
* yellow
* purple
* orange
]]
function init()
draw.Interval = 30
draw:Println("Hello from Lua")
end
local i = 0
local x = 0
function update()
i = i + 1
draw:Rect(100 + i , 100, 100, 100, "green")
if draw:KeyDown(68) then
x = x+2
elseif draw:KeyDown(65) then
x = x-2
end
draw:Circle(100+x, 100, 50, "blue")
end
Todo
- Add onKey events to Lua | Partially done with KeyDown()