LuaImg

Usage

LuaImg is a commandline interpreter that can execute snippets, files, or be an interactive console. To execute simple snippets from the shell, run luaimg as follows:

$ luaimg -e 'make(vec(100,100),3,vec(1,0,0)):save("red_square.png")'
$ ls -l red_square.png
-rw-r----- 1 user user 308 Oct 11 19:56 red_square.png

To execute a script file, use the -f option:

$ luaimg -f myfile.lua

The interpreter can execute multiple snippets and files, they are executed in the order they appear along the comandline. Any additional commandline parameters (ones that do not begin with a -) are available in the script as Lua varags (...). The -- parameter causes all subsequent commandline options to be treated as script arguments, as is standard in many unix shell executables.

$ luaimg -e 'print("foo")' -e 'print(...)' hello world
foo
hello    world

The -i parameter enters an interactive shell where LuaImg script fragments can be typed. This is extremely useful for debugging and rapid prototyping, and can be combined with the other parameters.

Finally, the -F parameter is a shorthand for -f --, and allows using a hashbang first line annotation for unix scripts. These scripts can then have execute permissions and be run as regular unix executables (with their own commandline parameters:

$ cat execute_me.lua
#!/usr/bin/luaimg -F
local name = select(1, ...)
print ("Hello "..name.."!")
$ chmod a+x execute_me.lua
$ ./execute_me.lua Dave
Hello Dave!

See the examples directory in the repository for examples of non-trivial programs. In particular the logo (seen on this web site) is generated with the logo.lua script in this directory.

Valid XHTML 1.0 Strict