Giter VIP home page Giter VIP logo

graph-toolkit's Introduction

Lua Graphics Toolkit

The Lua Graphics Toolkit is a Lua module designed for crafting plots and graphics animations through an easy-to-use Lua interface. This module is compatible with both Windows and Linux as a standard Lua module. Although it can function on macOS, it requires an X Window server.

To ensure high-quality rendering, the module employs the AntiGrain Geometry library. This allows for exceptional rendering quality via anti-aliasing and subpixel resolution.

It supports Lua versions 5.1, 5.4, and LuaJIT 2.0 or 2.1.

All functions are thoroughly documented in the user manual, and several examples are available in the git repository.

The toolkit offers a straightforward interface for plotting functions. However, users can also access detailed control options. These include customizing graphical elements such as colors, positions, and the rendering pipeline. Additionally, the module natively supports Bezier curves, thanks to the AGG library.

Further customization is available for axes, allowing for unique labels and even layered label systems.

Plot legends are also a feature, although with certain restrictions. Currently, legends cannot be placed inside the plot area.

Animations

The module facilitates the creation of animations through a layered mechanism and several methods for adding and clearing elements from the current layer.

To craft an animation, elements are added to the plot. To generate a new frame, the current layer is cleared using the plot:clear() method, allowing the addition of new elements for the next frame. The "sync" property can be set to "false" to accumulate changes, which can then be applied with plot:flush() to refresh the window.

Multiple layers can be used effectively in animations. One layer can hold static graphical elements, while another layer can be dedicated to dynamic elements, creating a more complex animation.

Building

The graphics module can be built either using the Meson build system or using GNU make.

To build the following development packages are required:

  • the freetype2 library
  • the corresponding Lua or LuaJIT development package

The AGG library is also required but, when using Meson, it will be automatically downloaded and built so the corresponding development package is not needed. When using the Makefile instead it is required to install the AGG library development package.

To build using Meson use the commands:

# The following command setup the build.
# Use the lua option to choose between: lua5.1, lua5.4 and luajit
# Meson will accept the following general options:
# - --prefix=<prefix-dir>
# - --buildtype=<release-or-debug>
meson setup -Dlua=lua5.4 build

# The following command will actually compile the library
meson compile -C .build

# Do the following to install. Meson accept a --destdir option to
# specify a destination directory for packaging.
meson install -C .build

To build using GNU Makefile please edit src/makeconfig to choose the Lua version to use or LuaJIT and the prefix directory, then use the commands:

make
make DESTDIR=<dest-dir> install

History

The Lua Graphics Module was previously part of GSL Shell where it is still used. By looking at GSL Shell you can find more example of its utilisation.

graph-toolkit's People

Contributors

franko avatar ladc avatar markuman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graph-toolkit's Issues

Binary for windows

Hi

Any chance of a version 1.0 binary for windows (preferably without the dependency upon pthreadGC2.dll) ? I can't get the current source to compile using TDM-GCC Compiler Suite for Windows Series 5.

Many thanks

Gavin

Lua 5.2 support

Continuing from #3 (comment)

the current version of the library won't work in Lua > 5.1; for one, it uses C API functions that were removed in 5.2 (e.g. lua_getfenv/lua_setfenv).

Your uses should be simple enough to replace with lua_getuservalue.

FWIW, I write my C libraries in 5.2 style, and get them to work in 5.1+luajit with compat-5.2, it works out quite well :)

compiling lua-graph failed

$ make clean
rm -f *.o *.so *.dll libgraphcore.so libnatwin.so
[markus@arch graph-toolkit]$ make
Compiling str.c
Compiling gs-types.c
Compiling lua-utils.c
Compiling lua-properties.c
Compiling gamma.cpp
Compiling printf_check.cpp
Compiling utils.cpp
Compiling window_registry.cpp
Compiling fonts_search_x11.cpp
Compiling image_write_x11.cpp
Compiling fonts.cpp
Compiling agg_font_freetype.cpp
Compiling plot.cpp
plot.cpp: In member function 'double plot::draw_axis_m(plot::axis_e, units&, const agg::trans_affine&, ptr_list<draw::text>&, double, agg::path_storage&, agg::path_storage&)':
plot.cpp:198:22: warning: '*((void*)(& bb)+8).agg::rect_base<double>::y2' may be used uninitialized in this function [-Wmaybe-uninitialized]
     opt_rect<double> bb;
                      ^
plot.cpp:198:22: warning: '*((void*)(& bb)+8).agg::rect_base<double>::x2' may be used uninitialized in this function [-Wmaybe-uninitialized]
plot.cpp:198:22: warning: '*((void*)(& bb)+8).agg::rect_base<double>::y1' may be used uninitialized in this function [-Wmaybe-uninitialized]
plot.cpp:198:22: warning: '*((void*)(& bb)+8).agg::rect_base<double>::x1' may be used uninitialized in this function [-Wmaybe-uninitialized]
Compiling plot-auto.cpp
Compiling units.cpp
Compiling colors.cpp
Compiling markers.cpp
Compiling draw_svg.cpp
Compiling canvas_svg.cpp
Compiling lua-draw.cpp
Compiling lua-text.cpp
Compiling text.cpp
Compiling agg-parse-trans.cpp
Compiling lua-plot.cpp
lua-plot.cpp: In function 'int plot_get_legend(lua_State*)':
lua-plot.cpp:832:27: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
     lua_rawgeti(L, -1, pos);  /* push leg_table[pos] */
                           ^
lua-plot.cpp: In function 'int plot_set_legend(lua_State*)':
lua-plot.cpp:799:27: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
     lua_rawseti(L, -2, pos);  /* leg_table[pos] = legend */
                           ^
lua-plot.cpp:774:26: note: 'pos' was declared here
     sg_plot::placement_e pos;
                          ^
Compiling bitmap-plot.cpp
Compiling lua-graph.cpp
gcc -fPIC -shared str.o gs-types.o lua-utils.o lua-properties.o gamma.o printf_check.o utils.o window_registry.o fonts_search_x11.o image_write_x11.o fonts.o agg_font_freetype.o plot.o plot-auto.o units.o colors.o markers.o draw_svg.o canvas_svg.o lua-draw.o lua-text.o text.o agg-parse-trans.o lua-plot.o bitmap-plot.o lua-graph.o -o libgraphcore.so -lfreetype  -lagg  -lX11  -lluajit-5.1  -lpthread -lsupc++
/usr/bin/ld: str.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
str.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:165: recipe for target 'libgraphcore.so' failed
make: *** [libgraphcore.so] Error 1

Any ideas? Adding -fPIC to line 165 doesn't solve this problem.

$ gcc --version
gcc (GCC) 4.9.1 20140903 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


$ luajit -v
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/


$ pacman -Qi agg
Name           : agg
Version        : 2.5-6
Description    : A High Quality Rendering Engine for C++
Architecture   : x86_64
URL            : http://pkgs.fedoraproject.org/cgit/agg.git
Licenses       : GPL
Groups         : None
Provides       : antigrain
Depends On     : gcc-libs  sdl  freetype2
Optional Deps  : None
Required By    : None
Optional For   : None
Conflicts With : None
Replaces       : antigrain
Installed Size : 1954.00 KiB
Packager       : Jan Alexander Steffens (heftig) <[email protected]>
Build Date     : Sun May 4 06:20:48 2014
Install Date   : Wed Oct 15 21:37:59 2014
Install Reason : Explicitly installed
Install Script : No
Validated By   : Signature

[markus@arch graph-toolkit]$ 

Add rockspec

Please publish a rockspec so that the library can be installed via luarocks (and used as a dependancy!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.