/nanovg-rs

Rust-language binding for the NanoVG vector graphics library

Primary LanguageRustMIT LicenseMIT

NanoVG Rust wrapper

Now with Cargo!

This is a Rust-language wrapper for the NanoVG vector-graphis library.

NanoVG is C code, and it supports several back-ends: GL2, GL3, GLES...

NanoVG is not an extremely complete or extensive implementation of vector graphics. It is however small and hardware-accelerated, which is what I want.

Screenshot

yay! screenshot works in rust demo!

Prerequisites

This build process will produce a Rust library, which includes the Rust wrapper for nanovg functions, and which statically links in those functions. NanoVG only does the graphics drawing, though; you'll need to be getting a GL context from somewhere. The examples use GLFW.

Premake4 is required for building NanoVG itself.

GLFW3 needs to be installed.

Building

Build using cargo:

  git clone https://github.com/KevinKelley/nanovg-rs
  cd nanovg-rs
  cargo build

To build the demo, then:

  cd examples/demo
  cargo build
  ./target/example

(note that font and image resources won't be found if you run from inside the target directory)

In the demo,

  • 'p' switches between pre- and un-premultiplied alpha;
  • 's' saves a screenshot;
  • and 'space' toggles scale/rotate of the pseudo-window stuff.

Used By

License

MIT, for this binding. NanoVG is released under the zlib license.

Links