Lua-gl

Graphical library to handle the hard parts of creating software like electronic schematic editor/flowchart creator/mind maps/block diagrams in Lua with just a few lines of code.

Learn More
Robot Image

Why Choose Lua-gl?

First why choose Lua? Lua is:

These reasons by themself make it a very powerful language for newcomers to adopt to get things done.

With these design choices for Lua-GL it simply makes things a lot easier, faster, interoperable and more scalable for projects using it.

Demo Project Example

Creating complex shapes by grouping

Lua-GL provides basic shapes which can be grouped to form complex shapes such as a PNP bipolar transistor symbol shown here in the demo application.

Adding ports to objects

Lua-GL provides mechanisms to add ports. A port is any point which is sticky to connectors. Your application decides and controls how they look. The demo application here shows ports being added to objects.

Adding connectors between ports

Lua-GL provides mechanisms to add connectors. Your application decides how they look or route. The demo application shows one implementation of the connectors that is possible.

Dragging objects

Lua-GL provides the mechanisms to drag objects/connectors. Dragging items maintains their connector interconnections. Your application decides how dragging behaves and looks. The demo application shows one implementation of dragging.

Dragging Connector Segments

The demo application shows here an implementation of dragging the parts of a connector to reshape it.

Autorouting

Lua-GL comes with its own auto-router to find the shortest path for connector routing if your application decides to use it. Your application can add its own router with routing policies quite easily. The demo application here shows the autorouter in action.

Installation and Usage

First of all, you should have an IUP and CD library on your local system.
Download IUP from link
Download CD from link
Install lua-gl using luarocks

luarocks install lua-gl

Some examples of using the library. Full details can be found in the documentation.
To use the module simply do

require("iuplua")
require("iupluaimglib")
require("cdlua")
require("iupluacd")

LGL = require("lua-gl")

Creating a canvas object

cnvobj = LGL.new{ grid_x = 40, grid_y = 40, width = 600, height = 300, gridVisibility = true }

cnvobj is an object of the IUP canvas. Canvas can be accessed by cnvobj like canvas = cnvobj.cnv and we can perform operations on canvas using cnvobj.

dlg = iup.dialog{ 
    iup.vbox{
        iup.label{title = "----------------Canvas---------------"},
        cnvobj.cnv,
    },
    title = "lua-gl",
}
dlg:showxy(iup.CENTER , iup.CENTER)

if iup.MainLoopLevel() == 0 then
   iup.MainLoop()
   iup.Close()
end