Introduction

rust-animation is an OpenGL based graphics library for creating hardware-accelerated user interfaces written in Rust. It allows us to implement a simple animated UI for embedded devices.

Note: this project is in early development stage so there would be a lot of changes without any notice.

Installation

rust-animation is written in Rust so you need to install Rust: * https://www.rust-lang.org/tools/install

If you build rust-animation in Windows, you have to install cmake first.

Note: rust-animation is tested in Ubuntu 20.04, Windows10, and Mac OSX.

There are several examples so you can build them as follows:

$ cargo build --example ani $ cargo build --example picture_viewer

Run

$ target/debug/examples/ani $ target/debug/examples/picture_viewer

Code examples

``` let mut play = Play::new("Animation test".tostring()); play.initialize(); let mut stage = Stage::new("stage".tostring(), 1920, 1080, None); stage.set_visible(true);

let mut actor = Actor::new("actor1".tostring(), 400, 225, None); actor.x = 100; actor.y = 100; actor.rotation = 5; actor.setimage("examples/splash.png".tostring());

// 1X -> 2X for 5 sec. actor.applyscaleanimation(1.0, 2.0, 5.0); actor.applytranslationxanimation(100, 600, 5.0); actor.applytranslationyanimation(100, 200, 5.0);

let mut actor2 = Play::newactor("actor2".tostring(), 120, 120, None); actor2.x = 100; actor2.y = 100; actor2.scalex = 1.5; actor2.scaley = 1.5; actor2.setcolor(0.0, 0.0, 1.0); // 0 degree -> 360 degree for 5 sec actor2.applyrotation_animation(0, 360, 5.0);

stage.addactor(actor); stage.addactor(actor2); play.addstage(stage);

```

The main loop of glfw: ``` while !window.shouldclose() { // events processevents(&mut window, &events);

play.render();

// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
window.swap_buffers();
glfw.poll_events();

} ```