6 releases (1 stable)

Uses old Rust 2015

1.0.2 Aug 27, 2018
1.0.1 Aug 25, 2018
0.4.2 Apr 12, 2018
0.3.0 Aug 4, 2015
0.2.0 May 3, 2015

#187 in Graphics APIs

Download history 10/week @ 2023-11-19 7/week @ 2023-11-26 3/week @ 2023-12-03 10/week @ 2023-12-17 6/week @ 2024-01-07 3/week @ 2024-01-14 1/week @ 2024-02-04 7/week @ 2024-02-11 19/week @ 2024-02-18 45/week @ 2024-02-25 22/week @ 2024-03-03

93 downloads per month
Used in 3 crates

MIT/Zlib

5MB
15K SLoC

C 13K SLoC // 0.1% comments Rust 2K SLoC // 0.0% comments Lua 177 SLoC

NanoVG - Rust Wrapper

NanoVG-RS is a wrapper around the NanoVG vector graphics library for the Rust programming language.

NanoVG is small antialiased vector graphics rendering library for OpenGL. It has lean API modeled after HTML5 canvas API. It is aimed to be a practical and fun toolset for building scalable user interfaces and visualizations.

NanoVG-RS provides a fully featured, functional, high-level and Rust-idiomatic API on top of the NanoVG C-API.

Building

We recommend grabbing the latest release from crates.io.

Alternatively, you can clone and build the library yourself:

git clone --recursive https://github.com/KevinKelley/nanovg-rs
cd nanovg-rs
cargo build --features "gl3"

This library comes with a couple examples:

  • very useful example called demo-glutin. If you want to make sure that nanovg is working on your system, clone and build this crate as shown above and run the command cargo run --example demo-glutin --features="gl3". This should produce a window similar to that below.
  • a clock example, 'demo-clock', because who doesn't like clocks? And I needed to get rotation transforms working. Run it with cargo run --example demo-clock --features "gl3"

Note that when running the examples, the needed resources might not be found if you run it without a cargo run --example command. Thist is just a working-directory path issue.

Usage

Add the following to your Cargo.toml:

[dependencies.nanovg]
version = "Use the latest version from crates.io"
features = ["glX"]

glX can be exactly one of gl2, gl3, gles2 or gles3, to specify the version of OpenGL to use. Use gl3 or gl2 for computers and gles3 or gles2 for mobile devices.

TODO: SIMPLE API GUIDE

Screenshots

You can see more screenshots here.

demo-ui Output of the demo-ui example.

Interesting Links

License and Credits

The binding is licensed under the MIT license. NanoVG is released under the zlib license.

Test-font Mechanic of the Heart by Agathe M.Joyce.

Dependencies