• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    C
  • License
    Creative Commons ...
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lion Vector Graphics

LVG (Lion Vector Graphics)

Build Status CircleCI Build Status Coverity Scan Build Status

LVG is a lightweight flash player replacement. Basic idea: we have some assets in a package and sctipts that renders them. It's designed to use a very small runtime (around 200kb without video codecs) for player and runs on android, ios, web and more.

Currently it uses C script to load and render assets. Why C script? Because C compiler is small, and runtime written in C, so no other language is needed and script can be compiled in to a save the space. Another reason is compatibility: lvg only exposes small API and opengl, with other scripting laguages we must do all from scratch, including GUI. But there are huge amount of already-written C code. Usually author prefer C++, but there also some reasons to use pure C for whole project:

  • We do not need to include libstdc++ for Android shared objects, which saves some .apk space (shared objects libs also usually duplicated for each supported architectue in .apk).
  • This reduces size of emscripten compiled WASM code (it's already relatively heavy).
  • Native C++ builds needs some attention for small code too. It's definetly possible to write small code with C++, but we need something like minicrt for each platform/compiler. See farbrauch code for example or something similar.
  • C++ code produces much more noisy .map files which makes profile/map file analysis bit more complicated. Projects like chromium also uses objects analysis tools (like dump-static-initializers.py), there also less noise with such tools.
  • Code can be ported to specific OS'es more easily.

Following assets currently supported:

  • SVG vector images (loaded using NanoSVG)
  • Raster images (loaded using stb_image.h)
  • MP3 files (loaded using minimp3)
  • Flash SWF files (can contain vector, raster, video and audio). All swf video codecs (h263,vp6,flashsv,flashsv2,h264) costs additional ~600kb.
  • Scripts using tcc or picoc

Render can be done using following backends:

Current Status

Works:

  • SVG, image, mp3 resources with tcc scripting.
  • SWF: shapes, images, video, audio (mp3, adpcm, pcm), limited action script 2 support, limited morph shapes support.

Not works:

  • SWF: clip layers
  • SWF: interpret action script 3
  • SWF: bitmap filters
  • SWF: network access

Demos

Basic svg demo (images clickable):

SVG Screenshot

NanoVG demo incapsulated in lvg:

NanoVG Screenshot

Nuklear GUI demo:

Nuklear Screenshot

Flash swf demo:

Flash Screenshot

Building

For now windows executables builds only on linux host using mingw. For windows and linux install all build dependencies with the following command:

apt-get install -qq -y git cmake meson yasm libglfw3-dev libsdl2-dev libavcodec-dev mingw-w64 wget

For macos brew must be installed:

brew install meson upx glfw sdl2 ffmpeg tcc

LVG uses meson as build system. Actual building with the following commands in project directory:

mkdir build
cd build
meson ..
ninja

Configuring

LVG can be configured to use different backends for platform, audio and video. You can see current configuration by executing mesonconf (or meson configure for newer meson versions) in build directory:

meson configure
...
Project options:
  Option        Description   Current Value Possible Values
  ------        -----------   ------------- ---------------
  AUDIO_SDL     AUDIO_SDL     true          [True, False]
  ENABLE_AUDIO  ENABLE_AUDIO  true          [True, False]
  ENABLE_SCRIPT ENABLE_SCRIPT true          [True, False]
  ENABLE_VIDEO  ENABLE_VIDEO  true          [True, False]
  PLATFORM_GLFW PLATFORM_GLFW true          [True, False]
  PLATFORM_SDL  PLATFORM_SDL  false         [True, False]
  RENDER_NANOVG RENDER_NANOVG true          [True, False]
  RENDER_NVPR   RENDER_NVPR   true          [True, False]
  SCRIPT_TCC    SCRIPT_TCC    true          [True, False]
  VIDEO_FFMPEG  VIDEO_FFMPEG  true          [True, False]
...

You can change configuration using meson commands. Example:

mesonconf -DENABLE_SCRIPT=False

Future

  • Use other scripting lanuages like luajit, JerryScript, muJS, mu, avian, ImpalaJIT, mochascript and AngelScript.
  • Speed up action script with jit like sljit.
  • Shaders and 3D support.
  • Parallel shape\image decoding and use file compression with parallel decoding support (like pbzip2).
  • More audio\video\codec backends.
  • SWF frame interpolation to get more fps than encoded in file. [Done]
  • Better than swf storage format using draco-like compression based on ANS.

Interesting graphics libraries

Flash related projects

LVG is developed and maintained by https://github.com/lieff